Class: ActiveRecord::JDBCError
- Inherits:
-
WrappedDatabaseException
- Object
- WrappedDatabaseException
- ActiveRecord::JDBCError
- Defined in:
- lib/arjdbc/jdbc/error.rb
Overview
Represents exceptions that have propagated up through the JDBC API.
Instance Method Summary collapse
-
#cause ⇒ Object
(also: #original_exception)
Likely (but not necessarily) the same as #jdbc_exception.
- #errno ⇒ Object deprecated Deprecated.
-
#error_code ⇒ Integer, NilClass
The DB (or JDBC driver implementation specific) vendor error code.
-
#initialize(message = nil, cause = $!) ⇒ JDBCError
constructor
A new instance of JDBCError.
-
#jdbc_exception ⇒ Object
(also: #sql_exception)
The full Java exception (SQLException) object that was raised (if any).
-
#recoverable? ⇒ Boolean
true if the current error might be recovered e.g.
- #set_backtrace(backtrace) ⇒ Object
-
#sql_state ⇒ String, NilClass
SQL code as standardized by ISO/ANSI and Open Group (X/Open), although some codes have been reserved for DB vendors to define for themselves.
-
#transient? ⇒ Boolean
true when a failed operation might be able to succeed when retried (e.g. timeouts).
Constructor Details
#initialize(message = nil, cause = $!) ⇒ JDBCError
Returns a new instance of JDBCError.
7 8 9 10 11 12 13 14 |
# File 'lib/arjdbc/jdbc/error.rb', line 7 def initialize( = nil, cause = $!) super( ( .nil? && cause ) ? cause. : ) if cause.is_a? Java::JavaSql::SQLException @jdbc_exception, @cause = cause, nil else @cause, @jdbc_exception = cause, nil end end |
Instance Method Details
#cause ⇒ Object Also known as: original_exception
Likely (but not necessarily) the same as #jdbc_exception.
47 |
# File 'lib/arjdbc/jdbc/error.rb', line 47 def cause; ( @cause ||= nil ) || jdbc_exception end |
#errno ⇒ Object
28 |
# File 'lib/arjdbc/jdbc/error.rb', line 28 def errno; error_code end |
#error_code ⇒ Integer, NilClass
The DB (or JDBC driver implementation specific) vendor error code.
19 20 21 22 23 24 25 |
# File 'lib/arjdbc/jdbc/error.rb', line 19 def error_code if ( @error_code ||= nil ).nil? @error_code = jdbc_exception ? jdbc_exception.getErrorCode : nil else @error_code end end |
#jdbc_exception ⇒ Object Also known as: sql_exception
Navigate through chained exceptions using jdbc_exception.next_exception
.
The full Java exception (SQLException) object that was raised (if any).
38 |
# File 'lib/arjdbc/jdbc/error.rb', line 38 def jdbc_exception; @jdbc_exception end |
#recoverable? ⇒ Boolean
true if the current error might be recovered e.g. by re-trying the transaction
42 |
# File 'lib/arjdbc/jdbc/error.rb', line 42 def recoverable?; jdbc_exception.is_a?(Java::JavaSql::SQLRecoverableException) end |
#set_backtrace(backtrace) ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/arjdbc/jdbc/error.rb', line 53 def set_backtrace(backtrace) @raw_backtrace = backtrace if ( nested = cause ) && ! nested.equal?(self) backtrace = backtrace - ( nested.respond_to?(:raw_backtrace) ? nested.raw_backtrace : nested.backtrace ) backtrace << "#{nested.backtrace.first}: #{nested.} (#{nested.class.name})" backtrace.concat nested.backtrace[1..-1] || [] end super(backtrace) end |
#sql_state ⇒ String, NilClass
SQL code as standardized by ISO/ANSI and Open Group (X/Open), although some codes have been reserved for DB vendors to define for themselves.
34 |
# File 'lib/arjdbc/jdbc/error.rb', line 34 def sql_state; jdbc_exception ? jdbc_exception.getSQLState : nil end |
#transient? ⇒ Boolean
true when a failed operation might be able to succeed when retried (e.g. timeouts)
44 |
# File 'lib/arjdbc/jdbc/error.rb', line 44 def transient?; jdbc_exception.is_a?(Java::JavaSql::SQLTransientException) end |