Created a special error class for handling graecful rollbacks (not sure if Madeleine can take it yet)
This commit is contained in:
parent
8f5ac3440a
commit
7780a13fe8
|
@ -42,6 +42,7 @@ end
|
||||||
|
|
||||||
require 'action_controller'
|
require 'action_controller'
|
||||||
require 'active_record_stub'
|
require 'active_record_stub'
|
||||||
|
require 'instiki_errors'
|
||||||
|
|
||||||
unless defined? RAILS_DEFAULT_LOGGER
|
unless defined? RAILS_DEFAULT_LOGGER
|
||||||
RAILS_DEFAULT_LOGGER = Logger.new(STDERR)
|
RAILS_DEFAULT_LOGGER = Logger.new(STDERR)
|
||||||
|
|
15
libraries/instiki_errors.rb
Normal file
15
libraries/instiki_errors.rb
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
# Model methods that want to rollback transactions gracefully
|
||||||
|
# (i.e, returning the user back to the form from which the request was posted)
|
||||||
|
# should raise Instiki::ValidationError.
|
||||||
|
#
|
||||||
|
# E.g. if a model object does
|
||||||
|
# raise "Foo: '#{foo}' is not equal to Bar: '#{bar}'" if (foo != bar)
|
||||||
|
#
|
||||||
|
# then the operation is not committed; Rails returns the user to the page
|
||||||
|
# where s/he was entering foo and bar, and the error message will be displayed
|
||||||
|
# on the page
|
||||||
|
|
||||||
|
module Instiki
|
||||||
|
class ValidationError < StandardError
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue