diff --git a/config/environment.rb b/config/environment.rb index f38efb72..6e038c7a 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -42,6 +42,7 @@ end require 'action_controller' require 'active_record_stub' +require 'instiki_errors' unless defined? RAILS_DEFAULT_LOGGER RAILS_DEFAULT_LOGGER = Logger.new(STDERR) diff --git a/libraries/instiki_errors.rb b/libraries/instiki_errors.rb new file mode 100644 index 00000000..52efc571 --- /dev/null +++ b/libraries/instiki_errors.rb @@ -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 \ No newline at end of file