Re: Good practice for error-handling

Patrick Hoeffel <[email protected]> Thu, 5 Sep 2002 13:29:17 -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_01C25512.867015A0
Content-Type: text/plain;
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Kim,

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.

Patrick Hoeffel


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


Hello,
=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
Thankful for any pointers,
Kim

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_01C25512.867015A0
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] Good practice for error-handling</TITLE>
</HEAD>
<BODY>

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

<P><FONT SIZE=3D2>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>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>Patrick Hoeffel</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 1:15 PM</FONT>
<BR><FONT SIZE=3D2>To: [email protected]</FONT>
<BR><FONT SIZE=3D2>Subject: [OLEDB_DEV] Good practice for =
error-handling</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>Hello,</FONT>
<BR><FONT SIZE=3D2>&nbsp;</FONT>
<BR><FONT SIZE=3D2>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><FONT SIZE=3D2>&nbsp;</FONT>
<BR><FONT SIZE=3D2>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><FONT SIZE=3D2>&nbsp;</FONT>
<BR><FONT SIZE=3D2>How can I manage this? Does RAISEERROR come out as =
an HRESULT?</FONT>
<BR><FONT SIZE=3D2>&nbsp;</FONT>
<BR><FONT SIZE=3D2>Thankful for any pointers,</FONT>
<BR><FONT SIZE=3D2>Kim</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_01C25512.867015A0--