Skip to content

Commit be44633

Browse files
authored
Translate exceptions (#1078)
1 parent 72f553f commit be44633

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/active_record/connection_adapters/sqlserver/database_statements.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,13 +309,17 @@ def do_execute(sql, name = "SQL")
309309
log(sql, name) { raw_connection_do(sql) }
310310
end
311311

312+
# TODO: Adapter should be refactored to use `with_raw_connection` to translate exceptions.
312313
def sp_executesql(sql, name, binds, options = {})
313314
options[:ar_result] = true if options[:fetch] != :rows
314315
unless without_prepared_statement?(binds)
315316
types, params = sp_executesql_types_and_parameters(binds)
316317
sql = sp_executesql_sql(sql, types, params, name)
317318
end
318319
raw_select sql, name, binds, options
320+
rescue => original_exception
321+
translated_exception = translate_exception_class(original_exception, sql, binds)
322+
raise translated_exception
319323
end
320324

321325
def sp_executesql_types_and_parameters(binds)

0 commit comments

Comments
 (0)