On 04/09/06, Gareth Adams
<gareth.adams-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> 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
Other than parsing .message, there''s no handy way I know to get the
error message produced by SQL Server. As errors thrown should
indicate exceptional circumstances, the messages within them are
really intended for debugging purposes, rather than to display to end
users.
The message you seem to be trying to extract looks more like a
validation failure. A better approach would be to perform validation
before calling the stored procedure. Other than that, parsing the
error message is your only hope.
Tom
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---