Re: how to catch custom errors raised in SP gracefully?

From: Mary Chipman (mchip_at_online.microsoft.com)
Date: 07/14/04


Date: Wed, 14 Jul 2004 09:03:04 -0400

Failure to return a result set isn't considered an error (or
InfoMessage) by the server. If you have client-side errors, then the
call never got to the server. Open a Profiler trace to see exactly
what is being passed back and forth between your app and SQLS.

--Mary

On Tue, 13 Jul 2004 14:42:44 -0500, " Bob" <bobatkpmg@yahoo.com>
wrote:

>Hi Mary:
>
>I think this fits my need the best. However, I can't get the event handler
>to throw a new exception, nothing happens. But if I put in
>Console.Writeline, or HttpResponse.Write(), the error message from the event
>argument can be printed out. Do you know why? Here's my code snippet:
>
> private static void OnInfoMessage(object sender, SqlInfoMessageEventArgs
>e) {
> System.Web.HttpContext.Current.Response.Write(e.Message + e.Source +
>e.Errors.Count.ToString() + "Bob");
> throw new Exception("Blah"); //This doesn't throw an exception.
> }
>
>And in my function that actually does the call to the DB, I have this:
>
>....................
> liveCmd.Connection.InfoMessage += new
>SqlInfoMessageEventHandler(OnInfoMessage);
> DataSet ds = DataHelper.ExecuteSelectQuery(liveCmd, string.Empty);
>....................
>
>
>"Mary Chipman" <mchip@online.microsoft.com> wrote in message
>news:s888f0d6njdhdkl5k39qvg20j3qessu4ub@4ax.com...
>> One way to handle it is to use output parameters instead of RAISERROR
>> to handle both server and user-defined errors. Raising exceptions is
>> always expensive, and coding your stored procedures to minimize
>> sending error messages back and forth across the wire is a good idea.
>> Anything that can be handled on the server should be, and the client
>> should get back a clear success/failure message for every operation
>> performed so that it can branch accordingly.
>>
>> --Mary
>>
>> On Tue, 13 Jul 2004 12:44:21 -0500, " Bob" <bobatkpmg@yahoo.com>
>> wrote:
>>
>> >In my stored procedure, I raise an error using RAISERROR. Seems it just
>> >comes out to the .NET code as a SqlException. Is there a way to
>> >differentiate my custom error from the raw SqlExceptions (like table is
>> >missing, FK violation etc), because if I purposely raise an error, I sure
>> >want to handle it differently.
>> >
>> >Thanks
>> >Bob
>> >
>>
>



Relevant Pages

  • RE: The object invoked has disconnected from its clients.
    ... The latest server Usage Report email only contained this error message. ... It is recommended that you contact Microsoft Customer ... Support Services via telephone so that a dedicated Support ... Professional can assist you recover the server in a more efficient manner. ...
    (microsoft.public.windows.server.sbs)
  • Re: startx fails
    ... Subject: startx fails ... Have you looked in the paths shown in the error message? ... configure the netscape http server. ... install, or one on which people have done lots of patches? ...
    (comp.unix.sco.misc)
  • Re: Publishing WebForms to Production System
    ... Its already Off but same error message. ... <!-- CUSTOM ERROR MESSAGES ... Set trace enabled="true" to enable application trace logging. ... > and upload the modified web.config file to your server. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Publishing WebForms to Production System
    ... Its already Off but same error message. ... <!-- CUSTOM ERROR MESSAGES ... Set trace enabled="true" to enable application trace logging. ... > and upload the modified web.config file to your server. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: FP 2003 message: An error occurred accessing Windows Sharepoint Services site files.
    ... Microsoft MVP - FrontPage ... local site from My Network Places, I got the attached error message. ... Scroll down to the Server Health section and click the link for Check ... Open your local site from there. ...
    (microsoft.public.frontpage.extensions.windowsnt)