I'm looking for ways to get hold of the error message produced by an SQL query.
The query in question is calling a stored procedure in a legacy MSSQL system, and an ActiveRecord::StatementInvalid exception is being raised. Is there any way to get information about the exception (like the error message) so it can be displayed to the user?
In a begin..rescue block I can access .message as follows, but I'd rather not be parsing that to get the error message on the third line for obvious reasons
irb(Mssql):005:0> err.message => "DBI::DatabaseError: Execute\n OLE error code:80040E14 in Microsoft OLE DB Provider for SQL Server\n Invalid surname, title or address.\n HRESU LT error code:0x80020009\n Exception occurred.: EXEC lgg_createuserdetails 'Gareth', [snip], 0"
Thanks guys, Gareth