#778: return error on attempt of creating duplicating users
This commit is contained in:
parent
dfe171abfe
commit
6a46eb3c2f
@ -20,7 +20,8 @@ module Connectors
|
||||
collection.insert(record.to_mongo_hash)
|
||||
record
|
||||
rescue Mongo::OperationFailure => e
|
||||
if e.message =~ /^11000/
|
||||
# exception's message doesn't always start from error code
|
||||
if e.message =~ /11000/
|
||||
resource_name = StringHelper.underscore_class(record.class)
|
||||
raise InvalidRecord.new("Duplicate key error: #{resource_name} with id '#{record.id}'")
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user