From 7780a13fe8f66f59bfbb0e18f91f067d699a2ded Mon Sep 17 00:00:00 2001 From: Alexey Verkhovsky Date: Mon, 17 Jan 2005 21:22:41 +0000 Subject: [PATCH] Created a special error class for handling graecful rollbacks (not sure if Madeleine can take it yet) --- config/environment.rb | 1 + libraries/instiki_errors.rb | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 libraries/instiki_errors.rb 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