Permalink
Browse files

Fix/add Database#database_error_classes in various adapters

  • Loading branch information...
1 parent eceba11 commit a01fdf8e6bf142d7977eab33ebe26d56a67fc5a9 @jeremyevans committed Oct 23, 2012
@@ -97,6 +97,10 @@ def commit_transaction(conn, opts={})
log_yield(TRANSACTION_COMMIT){conn.commit}
end
+ def database_error_classes
+ [StandardError]
+ end
+
def remove_transaction(conn, committed)
conn.auto_commit = true
ensure
@@ -116,6 +116,10 @@ def to_application_timestamp_db2(v)
private
+ def database_error_classes
+ [DB2Error]
+ end
+
def begin_transaction(conn, opts={})
log_yield(TRANSACTION_BEGIN){DB2CLI.SQLSetConnectAttr(conn, DB2CLI::SQL_ATTR_AUTOCOMMIT, DB2CLI::SQL_AUTOCOMMIT_OFF)}
end
@@ -309,6 +309,10 @@ def commit_transaction(conn, opts={})
log_yield(TRANSACTION_COMMIT){conn.commit}
end
+ def database_error_classes
+ [Connection::Error]
+ end
+
# Don't convert smallint to boolean for the metadata
# dataset, since the DB2 metadata does not use
# boolean columns, and some smallint columns are
@@ -334,6 +334,10 @@ def cps_sync(conn, &block)
@connection_prepared_statements_mutex.synchronize{yield(@connection_prepared_statements[conn] ||= {})}
end
+ def database_error_classes
+ [NativeException]
+ end
+
# Raise a disconnect error if the SQL state of the cause of the exception indicates so.
def disconnect_error?(exception, opts)
cause = exception.respond_to?(:cause) ? exception.cause : exception
@@ -134,6 +134,10 @@ def cursor_bind_params(conn, cursor, args)
end
end
+ def database_error_classes
+ [OCIException, RuntimeError]
+ end
+
def execute_prepared_statement(conn, type, name, opts)
ps = prepared_statement(name)
sql = ps.prepared_sql
@@ -461,6 +461,10 @@ def connection_configuration_sqls
sqls
end
+ def database_error_classes
+ [PGError]
+ end
+
# Execute the prepared statement with the given name on an available
# connection, using the given args. If the connection has not prepared
# a statement with the given name yet, prepare it. If the connection
@@ -250,9 +250,10 @@ def execute_prepared_statement(conn, type, name, opts, &block)
end
end
- # The main error class that SQLite3 raises
+ # SQLite3 raises ArgumentError in addition to SQLite3::Exception in
+ # some cases, such as operations on a closed database.
def database_error_classes
- [SQLite3::Exception]
+ [SQLite3::Exception, ArgumentError]
end
end

0 comments on commit a01fdf8

Please sign in to comment.