aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/base.rb
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2009-06-26 16:59:27 +1200
committerMichael Koziarski <michael@koziarski.com>2009-06-26 17:01:21 +1200
commitb5dfdc714fab7d2836e0a979ca88b4a17db9ec06 (patch)
tree642341d623b59be813290765dd08dc4b64eab464 /activerecord/lib/active_record/base.rb
parent00a5fd3d18ac908af688c5944922cf69c56e850b (diff)
downloadrails-b5dfdc714fab7d2836e0a979ca88b4a17db9ec06.tar.gz
rails-b5dfdc714fab7d2836e0a979ca88b4a17db9ec06.tar.bz2
rails-b5dfdc714fab7d2836e0a979ca88b4a17db9ec06.zip
Make sure the wrapped exceptions also have the original exception available.
[#2419 state:committed]
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rwxr-xr-xactiverecord/lib/active_record/base.rb15
1 files changed, 13 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 027ab8af9e..f1b7c323dc 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -67,12 +67,23 @@ module ActiveRecord #:nodoc:
class StatementInvalid < ActiveRecordError
end
+ # Parent class for all specific exceptions which wrap database driver exceptions
+ # provides access to the original exception also.
+ class WrappedDatabaseException < StatementInvalid
+ attr_reader :original_exception
+
+ def initialize(message, original_exception)
+ super(message)
+ @original_exception, = original_exception
+ end
+ end
+
# Raised when a record cannot be inserted because it would violate a uniqueness constraint.
- class RecordNotUnique < StatementInvalid
+ class RecordNotUnique < WrappedDatabaseException
end
# Raised when a record cannot be inserted or updated because it references a non-existent record.
- class InvalidForeignKey < StatementInvalid
+ class InvalidForeignKey < WrappedDatabaseException
end
# Raised when number of bind variables in statement given to <tt>:condition</tt> key (for example, when using +find+ method)