Re: SV: Good practice for error-handling

Kim Gräsman <[email protected]> Fri, 6 Sep 2002 09:48:42 +0200
Newsgroups gmane.comp.windows.devel.oledb.devel
Message-ID <[email protected]>
This is a multi-part message in MIME format.

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

Thanks a bunch. I'll try it out later.
=20
// kim

-----Original Message-----
From: Patrick Hoeffel [mailto:[email protected]]
Sent: den 5 september 2002 22:12
To: [email protected]
Subject: Re: SV: Good practice for error-handling



Kim,=20

It will be in OLEDB's error collection.=20

Patrick=20


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


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

        -----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=20
       =20
       =20

        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.

       =20
        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.

       =20
        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,=20
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.=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.

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

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<TITLE>RE: [OLEDB_DEV] SV: Good practice for error-handling</TITLE>

<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR></HEAD>
<BODY>
<DIV><SPAN class=3D080204807-06092002><FONT face=3D"Courier New" =
color=3D#000080=20
size=3D2>Thanks a bunch. I'll try it out later.</FONT></SPAN></DIV>
<DIV><SPAN class=3D080204807-06092002><FONT face=3D"Courier New" =
color=3D#000080=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D080204807-06092002><FONT face=3D"Courier New" =
color=3D#000080=20
size=3D2>// kim</FONT></SPAN></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000080 2px =
solid">
  <DIV class=3DOutlookMessageHeader dir=3Dltr align=3Dleft><FONT =
face=3DTahoma=20
  size=3D2>-----Original Message-----<BR><B>From:</B> Patrick Hoeffel=20
  [mailto:[email protected]]<BR><B>Sent:</B> den 5 september =
2002=20
  22:12<BR><B>To:</B> [email protected]<BR><B>Subject:</B> =
Re: SV:=20
  Good practice for error-handling<BR><BR></FONT></DIV>
  <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=20
  Gr=E4sman [<A=20
  =
href=3D"mailto:[email protected]">mailto:[email protected]</A>]</=
FONT>=20
  <BR><FONT size=3D2>Sent: Thursday, September 05, 2002 2:10 PM</FONT> =
<BR><FONT=20
  size=3D2>To: [email protected]</FONT> <BR><FONT =
size=3D2>Subject:=20
  [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=20
  size=3D2>Thanks a lot for the info. Does it end up in the standard COM =
error=20
  info, or OLEDB's own error collection?</FONT> <BR><FONT =
size=3D2>&nbsp;</FONT>=20
  <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=20
  meddelande----- </FONT><BR><FONT=20
  size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Fr=E5n: Patrick =
Hoeffel [<A=20
  =
href=3D"mailto:[email protected]">mailto:Pat.Hoeffel@CONFIGUR=
ESOFT.COM</A>]=20
  </FONT><BR><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
Skickat: to=20
  2002-09-05 21:29 </FONT><BR><FONT=20
  size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Till:=20
  [email protected] </FONT><BR><FONT=20
  size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Kopia: =
</FONT><BR><FONT=20
  size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =C4mne: Re: Good =
practice for=20
  error-handling</FONT> <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
  <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </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()=20
  call will return a failed HRESULT if you RAISEERROR. We do this =
routinely. The=20
  text of the raised error will be returned so that you display it to =
the user=20
  or log it or whatever you want to do. Take note, however, of the error =
level=20
  you indicate in your error. RAISEERROR with error level 18 will cause =
the=20
  stored procedure to exit immediately, while lower error levels (I =
don't=20
  remember the exact mappings - check Books Online) will still return an =
error=20
  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=20
  returned just like any other OLE DB text messages. Let me know if you =
need=20
  sample code. </FONT></P>
  <P><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Patrick =
Hoeffel=20
  </FONT></P><BR>
  <P><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
-----Original=20
  Message----- </FONT><BR><FONT=20
  size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; From: Kim =
Gr=E4sman [<A=20
  =
href=3D"mailto:[email protected]">mailto:[email protected]</A>]=20
  </FONT><BR><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
Sent:=20
  Thursday, September 05, 2002 1:15 PM </FONT><BR><FONT=20
  size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; To:=20
  [email protected] </FONT><BR><FONT=20
  size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Subject: =
[OLEDB_DEV] Good=20
  practice for error-handling </FONT></P><BR>
  <P><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Hello,=20
  </FONT><BR><FONT =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
  </FONT><BR><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
I've been a=20
  bit unhappy with our error handling for a while. We've got a bunch of =
COM=20
  components using the ATL OLEDB wrappers exclusively to execute stored=20
  procedures.</FONT></P>
  <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR><FONT=20
  size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Sometimes the sp's =
are=20
  simple SELECT's, and sometimes they contain more logic. For the latter =

  category, sometimes I feel like raising specific errors on sp-logic =
rather=20
  than referential integrity.</FONT></P>
  <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR><FONT=20
  size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; How can I manage =
this? Does=20
  RAISEERROR come out as an HRESULT? </FONT><BR><FONT=20
  size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
</FONT><BR><FONT=20
  size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Thankful for any =
pointers,=20
  </FONT><BR><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
Kim=20
  </FONT></P>
  <P><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; You can =
read=20
  messages from the OLEDB_DEV archive, unsubscribe from OLEDB_DEV,=20
  </FONT><BR><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
or=20
  subscribe to other DevelopMentor lists at <A =
href=3D"http://discuss.develop.com"=20
  target=3D_blank>http://discuss.develop.com</A>. </FONT></P>
  <P><FONT size=3D2>You can read messages from the OLEDB_DEV archive, =
unsubscribe=20
  from OLEDB_DEV, or subscribe to other DevelopMentor lists at <A=20
  href=3D"http://discuss.develop.com"=20
  target=3D_blank>http://discuss.develop.com</A>. </FONT></P>
  <P><FONT size=3D2>You can read messages from the OLEDB_DEV archive, =
unsubscribe=20
  from OLEDB_DEV,</FONT> <BR><FONT size=3D2>or subscribe to other =
DevelopMentor=20
  lists at <A href=3D"http://discuss.develop.com"=20
  target=3D_blank>http://discuss.develop.com</A>.</FONT> </P>You can =
read messages=20
  from the OLEDB_DEV archive, unsubscribe from OLEDB_DEV, or subscribe =
to other=20
  DevelopMentor lists at http://discuss.develop.com. =
</BLOCKQUOTE></BODY></HTML>
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_01C25579.D20BB756--