By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,978 Members | 1,019 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,978 IT Pros & Developers. It's quick & easy.

class to display calling routine in error

P: n/a
I have a public class that I use to read columns out of a SQL database.

In the try, catch, loop I want to display the error, and in the error I
want to display the calling routine (and helpfully the line # from the
calling routine).

Is that possible? The stacktrace gives me the system information (at
system.data.sqlclient.sqlconnection.onerror, etc). I am looking for my
routine that called it.

Darin

*** Sent via Developersdex http://www.developersdex.com ***
Jun 19 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Jun 19, 11:23 am, Darin <darin_nospam@nospameverwrote:
I have a public class that I use to read columns out of a SQL database.

In the try, catch, loop I want to display the error, and in the error I
want to display the calling routine (and helpfully the line # from the
calling routine).

Is that possible? The stacktrace gives me the system information (at
system.data.sqlclient.sqlconnection.onerror, etc). I am looking for my
routine that called it.

Darin

*** Sent via Developersdexhttp://www.developersdex.com***
I would suggest hardcoding a msgbox for intermediate debugging. In
the catch part, use the Msgbox(label where and why and add your
Exception value (ex.ToString)).

Jun 19 '07 #2

P: n/a
On Jun 19, 11:28 am, Lucas <lucaslshaf...@gmail.comwrote:
On Jun 19, 11:23 am, Darin <darin_nospam@nospameverwrote:
I have a public class that I use to read columns out of a SQL database.
In the try, catch, loop I want to display the error, and in the error I
want to display the calling routine (and helpfully the line # from the
calling routine).
Is that possible? The stacktrace gives me the system information (at
system.data.sqlclient.sqlconnection.onerror, etc). I am looking for my
routine that called it.
Darin
*** Sent via Developersdexhttp://www.developersdex.com***

I would suggest hardcoding a msgbox for intermediate debugging. In
the catch part, use the Msgbox(label where and why and add your
Exception value (ex.ToString)).
try this.

Try
do.Something
Catch ex As SqlClient.SqlException
MsgBox("Problem Here" & vbCrLf & ex.ToString,
MsgBoxStyle.Information, "Inside the Loop")
End Try

You can play around with the exception members. This exception would
retrieve the sys info relative to the SQL client.

Jun 19 '07 #3

P: n/a
On Jun 19, 11:33 am, Lucas <lucaslshaf...@gmail.comwrote:
On Jun 19, 11:28 am, Lucas <lucaslshaf...@gmail.comwrote:


On Jun 19, 11:23 am, Darin <darin_nospam@nospameverwrote:
I have a public class that I use to read columns out of a SQL database.
In the try, catch, loop I want to display the error, and in the error I
want to display the calling routine (and helpfully the line # from the
calling routine).
Is that possible? The stacktrace gives me the system information (at
system.data.sqlclient.sqlconnection.onerror, etc). I am looking for my
routine that called it.
Darin
*** Sent via Developersdexhttp://www.developersdex.com***
I would suggest hardcoding a msgbox for intermediate debugging. In
the catch part, use the Msgbox(label where and why and add your
Exception value (ex.ToString)).

try this.

Try
do.Something
Catch ex As SqlClient.SqlException
MsgBox("Problem Here" & vbCrLf & ex.ToString,
MsgBoxStyle.Information, "Inside the Loop")
End Try

You can play around with the exception members. This exception would
retrieve the sys info relative to the SQL client.- Hide quoted text -

- Show quoted text -
Later, once intermediate debugging is done. You can use the catch to
write to a log file or however you will record your error handling.

Jun 19 '07 #4

P: n/a
Darin wrote:
In the try, catch, loop I want to display the error
.... that would be ex.Message ...
and in the error I want to display the calling routine
(and helpfully the line # from the calling routine).
That's in the StackTrace, not the message.
Is that possible? The stacktrace gives me the system information (at
system.data.sqlclient.sqlconnection.onerror, etc). I am looking for my
routine that called it.
The StackTrace should include /every/ method in the current call chain
from the method at which you first entered the assembly, usually Main()
for an executable, all the way down to the method that threw the Exception.

ex.ToString() gets you the whole shooting match in one, giant, loggable
chunk.

If you really /need/ line numbers (although, personally, I think them
unnecessary) then you have to ship the .pdb file alongside your
executable; the run-time will interrogate this when the Exception is
constructed.

HTH,
Phill W.
Jun 20 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.