Sub name and line number

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

For error logging purpose, is it possible to get from the vb system feature
the SUB name and the line number?

Thanks

Regards
 
The exception should already return the sub name (actually the whole call
stack). AFAIK you can't get the line number in a release build (even with
PDBs if for nothing else because compiler optimizations are likely to break
the code/line association anyway). Breaking down a long procedure into
smaller units may help.
 
Hi

For error logging purpose, is it possible to get from the vb system feature
the SUB name and the line number?

Thanks

Regards

AFAIK, when the release version is used, you will only be able to get
the il name of the method, and not what you actually named it (and if
you obfuscated the code good luck getting anything useful!). The good
news is the the Exception object contains a StackTrace property which
should give you this information. I believe the line number will
vanish completely in the release version.

Usually, you can figure out where something went wrong with just the
exception message and stack trace, though not always. Typically, I log
a timestamp, who the user was, the exception's message and stack trace
as well as any inner exceptions. If I can't figure what happened from
the message and trace I can go to the user and ask them what happened.
(Be warned I work on internal programs only - so I have a bit more
luxury when it comes to communicating with my end-users. It is
generally a bad idea to really on your consumers to find your bugs!)

Thanks,

Seth Rowe
 
Back
Top