Re: SV: Good practice for error-handling

Patrick Hoeffel <[email protected]> Thu, 5 Sep 2002 14:12:03 -0600
Newsgroups gmane.comp.windows.devel.oledb.devel
Message-ID <[email protected]>
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C25518.80085140
Content-Type: text/plain;
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Kim,

It will be in OLEDB's error collection.

Patrick


-----Original Message-----
From: Kim Gr=E4sman [mailto:[email protected]]
Sent: Thursday, September 05, 2002 2:10 PM
To: [email protected]
Subject: [OLEDB_DEV] SV: Good practice for error-handling


Patrick,
=20
Thanks a lot for the info. Does it end up in the standard COM error =
info, or
OLEDB's own error collection?
=20
Cheers,
Kim

        -----Ursprungligt meddelande-----=20
        Fr=E5n: Patrick Hoeffel [mailto:[email protected]]=20
        Skickat: to 2002-09-05 21:29=20
        Till: [email protected]=20
        Kopia:=20
        =C4mne: Re: Good practice for error-handling
=09
=09

        Kim,=20

        Yes, the Open() call will return a failed HRESULT if you =
RAISEERROR.
We do this routinely. The text of the raised error will be returned so =
that
you display it to the user or log it or whatever you want to do. Take =
note,
however, of the error level you indicate in your error. RAISEERROR with
error level 18 will cause the stored procedure to exit immediately, =
while
lower error levels (I don't remember the exact mappings - check Books
Online) will still return an error result and text, but will allow the
procedure to finish.

        The text is returned just like any other OLE DB text messages. =
Let
me know if you need sample code.=20

        Patrick Hoeffel=20


        -----Original Message-----=20
        From: Kim Gr=E4sman [mailto:[email protected]]=20
        Sent: Thursday, September 05, 2002 1:15 PM=20
        To: [email protected]=20
        Subject: [OLEDB_DEV] Good practice for error-handling=20


        Hello,=20
         =20
        I've been a bit unhappy with our error handling for a while. =
We've
got a bunch of COM components using the ATL OLEDB wrappers exclusively =
to
execute stored procedures.

=09
        Sometimes the sp's are simple SELECT's, and sometimes they =
contain
more logic. For the latter category, sometimes I feel like raising =
specific
errors on sp-logic rather than referential integrity.

=09
        How can I manage this? Does RAISEERROR come out as an HRESULT?=20
         =20
        Thankful for any pointers,=20
        Kim=20

        You can read messages from the OLEDB_DEV archive, unsubscribe =
from
OLEDB_DEV,=20
        or subscribe to other DevelopMentor lists at
http://discuss.develop.com.=20

You can read messages from the OLEDB_DEV archive, unsubscribe from
OLEDB_DEV, or subscribe to other DevelopMentor lists at
http://discuss.develop.com.=20

You can read messages from the OLEDB_DEV archive, unsubscribe from
OLEDB_DEV,
or subscribe to other DevelopMentor lists at =
http://discuss.develop.com.

You can read messages from the OLEDB_DEV archive, unsubscribe from OLEDB_DEV,
or subscribe to other DevelopMentor lists at http://discuss.develop.com.

------_=_NextPart_001_01C25518.80085140
Content-Type: text/html;
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2653.12">
<TITLE>RE: [OLEDB_DEV] SV: Good practice for error-handling</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=3D2>Kim,</FONT>
</P>

<P><FONT SIZE=3D2>It will be in OLEDB's error collection.</FONT>
</P>

<P><FONT SIZE=3D2>Patrick</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>-----Original Message-----</FONT>
<BR><FONT SIZE=3D2>From: Kim Gr=E4sman [<A =
HREF=3D"mailto:[email protected]">mailto:[email protected]</A>]<=
/FONT>
<BR><FONT SIZE=3D2>Sent: Thursday, September 05, 2002 2:10 PM</FONT>
<BR><FONT SIZE=3D2>To: [email protected]</FONT>
<BR><FONT SIZE=3D2>Subject: [OLEDB_DEV] SV: Good practice for =
error-handling</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>Patrick,</FONT>
<BR><FONT SIZE=3D2>&nbsp;</FONT>
<BR><FONT SIZE=3D2>Thanks a lot for the info. Does it end up in the =
standard COM error info, or OLEDB's own error collection?</FONT>
<BR><FONT SIZE=3D2>&nbsp;</FONT>
<BR><FONT SIZE=3D2>Cheers,</FONT>
<BR><FONT SIZE=3D2>Kim</FONT>
</P>

<P><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
-----Ursprungligt meddelande----- </FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Fr=E5n: =
Patrick Hoeffel [<A =
HREF=3D"mailto:[email protected]">mailto:Pat.Hoeffel@CONFIGU=
RESOFT.COM</A>] </FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Skickat: =
to 2002-09-05 21:29 </FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Till: =
[email protected] </FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Kopia: =
</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =C4mne: =
Re: Good practice for error-handling</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
</P>

<P><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Kim, =
</FONT>
</P>

<P><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Yes, the =
Open() call will return a failed HRESULT if you RAISEERROR. We do this =
routinely. The text of the raised error will be returned so that you =
display it to the user or log it or whatever you want to do. Take note, =
however, of the error level you indicate in your error. RAISEERROR with =
error level 18 will cause the stored procedure to exit immediately, =
while lower error levels (I don't remember the exact mappings - check =
Books Online) will still return an error result and text, but will =
allow the procedure to finish.</FONT></P>

<P><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The text =
is returned just like any other OLE DB text messages. Let me know if =
you need sample code. </FONT>
</P>

<P><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Patrick =
Hoeffel </FONT>
</P>
<BR>

<P><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
-----Original Message----- </FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; From: Kim =
Gr=E4sman [<A =
HREF=3D"mailto:[email protected]">mailto:[email protected]</A>] =
</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Sent: =
Thursday, September 05, 2002 1:15 PM </FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; To: =
[email protected] </FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Subject: =
[OLEDB_DEV] Good practice for error-handling </FONT>
</P>
<BR>

<P><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Hello, =
</FONT>
<BR><FONT =
SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; I've been =
a bit unhappy with our error handling for a while. We've got a bunch of =
COM components using the ATL OLEDB wrappers exclusively to execute =
stored procedures.</FONT></P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Sometimes =
the sp's are simple SELECT's, and sometimes they contain more logic. =
For the latter category, sometimes I feel like raising specific errors =
on sp-logic rather than referential integrity.</FONT></P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; How can I =
manage this? Does RAISEERROR come out as an HRESULT? </FONT>
<BR><FONT =
SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Thankful =
for any pointers, </FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Kim =
</FONT>
</P>

<P><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; You can =
read messages from the OLEDB_DEV archive, unsubscribe from OLEDB_DEV, =
</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; or =
subscribe to other DevelopMentor lists at <A =
HREF=3D"http://discuss.develop.com" =
TARGET=3D"_blank">http://discuss.develop.com</A>. </FONT>
</P>

<P><FONT SIZE=3D2>You can read messages from the OLEDB_DEV archive, =
unsubscribe from OLEDB_DEV, or subscribe to other DevelopMentor lists =
at <A HREF=3D"http://discuss.develop.com" =
TARGET=3D"_blank">http://discuss.develop.com</A>. </FONT></P>

<P><FONT SIZE=3D2>You can read messages from the OLEDB_DEV archive, =
unsubscribe from OLEDB_DEV,</FONT>
<BR><FONT SIZE=3D2>or subscribe to other DevelopMentor lists at <A =
HREF=3D"http://discuss.develop.com" =
TARGET=3D"_blank">http://discuss.develop.com</A>.</FONT>
</P>

</BODY>
You can read messages from the OLEDB_DEV archive, unsubscribe from OLEDB_DEV,
or subscribe to other DevelopMentor lists at http://discuss.develop.com.
</HTML>
------_=_NextPart_001_01C25518.80085140--