diff options
author | Michael Koziarski <michael@koziarski.com> | 2009-06-26 16:59:27 +1200 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2009-06-26 17:01:21 +1200 |
commit | b5dfdc714fab7d2836e0a979ca88b4a17db9ec06 (patch) | |
tree | 642341d623b59be813290765dd08dc4b64eab464 /activerecord/lib/active_record/base.rb | |
parent | 00a5fd3d18ac908af688c5944922cf69c56e850b (diff) | |
download | rails-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-x | activerecord/lib/active_record/base.rb | 15 |
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) |