class to display calling routine in error

  • Thread starter Thread starter Darin
  • Start date Start date
D

Darin

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
 
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)).
 
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.
 
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.
 
Darin said:
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.
 
Back
Top