Skip to content

Commit

Permalink
Currently, using save! is unusable in the case that you want to be ab…
Browse files Browse the repository at this point in the history
…le programmatically handle specific validation errors. My proposed change also matches the way activerecord handles save! validation errors -- see docs for the equivalent class in active record here: http://api.rubyonrails.org/classes/ActiveRecord/RecordInvalid.html
  • Loading branch information
Michael Wasser committed Jan 18, 2012
1 parent 76d6bd6 commit 096d351
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/mongo_mapper/exceptions.rb
Expand Up @@ -14,7 +14,10 @@ class NotSupported < Error; end

# raised when document not valid and using !
class DocumentNotValid < Error
attr_reader :document

def initialize(document)
@document = document
super("Validation failed: #{document.errors.full_messages.join(", ")}")
end
end
Expand Down

0 comments on commit 096d351

Please sign in to comment.