aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/errors.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2013-04-23 17:26:16 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2013-04-28 20:59:30 -0700
commit60bb1333c6f11dd89b8422908f974b5a6839f4e7 (patch)
tree15118594a9030a7225d77d5812a38db0b890971c /activerecord/lib/active_record/errors.rb
parent226de24fa2c9c402495287f5d8153e132759c8c8 (diff)
downloadrails-60bb1333c6f11dd89b8422908f974b5a6839f4e7.tar.gz
rails-60bb1333c6f11dd89b8422908f974b5a6839f4e7.tar.bz2
rails-60bb1333c6f11dd89b8422908f974b5a6839f4e7.zip
StatementInvalid takes WrappedDatabaseException's place
Diffstat (limited to 'activerecord/lib/active_record/errors.rb')
-rw-r--r--activerecord/lib/active_record/errors.rb21
1 files changed, 11 insertions, 10 deletions
diff --git a/activerecord/lib/active_record/errors.rb b/activerecord/lib/active_record/errors.rb
index c615d59725..cd31147414 100644
--- a/activerecord/lib/active_record/errors.rb
+++ b/activerecord/lib/active_record/errors.rb
@@ -57,24 +57,25 @@ module ActiveRecord
class RecordNotDestroyed < ActiveRecordError
end
- # Raised when SQL statement cannot be executed by the database (for example, it's often the case for
- # MySQL when Ruby driver used is too old).
+ # Superclass for all database execution errors.
+ #
+ # Wraps the underlying database error as +original_exception+.
class StatementInvalid < ActiveRecordError
+ attr_reader :original_exception
+
+ def initialize(message, original_exception = nil)
+ super(message)
+ @original_exception = original_exception
+ end
end
# Raised when SQL statement is invalid and the application gets a blank result.
class ThrowResult < ActiveRecordError
end
- # Parent class for all specific exceptions which wrap database driver exceptions
- # provides access to the original exception also.
+ # Defunct wrapper class kept for compatibility.
+ # +StatementInvalid+ wraps the original exception now.
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.