|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
current function / sub name ?Hey Guys!
is there anyway to get in runtime current function or sub name ? Daniel ok
the answer is: msgbox(System.Reflection.MethodBase.GetCurrentMethod.Name) "Brahm" <daniel.br***@contronic.com.br> escreveu na mensagem is there anyway to get in runtime current function or sub name ?news:O9gn43PgGHA.4708@TK2MSFTNGP04.phx.gbl... Hey Guys! Daniel Brahm,
You found your answer, but I am always curious why somebody needs this kind of information, while he is in fact in the sub? Cor Show quoteHide quote "Brahm" <daniel.br***@contronic.com.br> schreef in bericht news:O9gn43PgGHA.4708@TK2MSFTNGP04.phx.gbl... > Hey Guys! > > is there anyway to get in runtime current function or sub name ? > > Daniel > > We, for one, use this for code reusability, whereby all functions/subs that
can throw an error will call a global error message handler that logs the message for troubleshooting when things goes wrong. Can't always rely on the user to give us the details of the error. With this we know where and when the error occurred. Show quoteHide quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:%23VMQe9VgGHA.3984@TK2MSFTNGP02.phx.gbl... > Brahm, > > You found your answer, but I am always curious why somebody needs this > kind of information, while he is in fact in the sub? > > Cor > > "Brahm" <daniel.br***@contronic.com.br> schreef in bericht > news:O9gn43PgGHA.4708@TK2MSFTNGP04.phx.gbl... >> Hey Guys! >> >> is there anyway to get in runtime current function or sub name ? >> >> Daniel >> >> > > > We, for one, use this for code reusability, whereby all functions/subs But you are in the methode, why do you than need it to get it in that > that can throw an error will call a global error message handler that logs > the message for troubleshooting when things goes wrong. Can't always rely > on the user to give us the details of the error. With this we know where > and when the error occurred. > difficult making only your program larger way? Call("MyMethode") seems for me easier than Call(System.Reflection.MethodBase.GetCurrentMethod.Name) Therefore I still don't understand it? Cor Are you saying that since you're already in the method then to call the
global error handler and pass it the method/function name? If so, it's too much of a hassle when you have so many subs/functions to work with. Like I said, we want reusability. For example, copy Call("MyHandler") everywhere I need a global error handler. However, I think I should bank on the call stack for the global handler now. We do use a global Unhandled Exception handler to capture any errors and it'll be nice to use the call stack to get the sub/function name instead as suggested by Martin. Show quoteHide quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:eCHQwdYgGHA.3900@TK2MSFTNGP05.phx.gbl... >> We, for one, use this for code reusability, whereby all functions/subs >> that can throw an error will call a global error message handler that >> logs the message for troubleshooting when things goes wrong. Can't >> always rely on the user to give us the details of the error. With this >> we know where and when the error occurred. >> > But you are in the methode, why do you than need it to get it in that > difficult making only your program larger way? > > Call("MyMethode") seems for me easier than > Call(System.Reflection.MethodBase.GetCurrentMethod.Name) > > Therefore I still don't understand it? > > Cor > "+Vice" <tonyp***@earthlink.net> wrote in Use Exceptions - you can get a full call stack...news:##6gMZYgGHA.4144@TK2MSFTNGP02.phx.gbl: > We, for one, use this for code reusability, whereby all functions/subs > that can throw an error will call a global error message handler that > logs the message for troubleshooting when things goes wrong. Can't > always rely on the user to give us the details of the error. With > this we know where and when the error occurred. You're probably right, I need to look into that, all I really need to see is
the function/sub where the error began. I think the trouble I was having with that, although I did not search deeper, was when a sub/function has an error handler that calls a function that doesn't and so the call stack incorrectly stated the function where the error was. Anyway, I'll have to research further just never bothered. Show quoteHide quote "Martin Milan" <I***@m.i.do> wrote in message news:Xns97D0BF65EBFC8I8spmido@194.117.143.53... > "+Vice" <tonyp***@earthlink.net> wrote in > news:##6gMZYgGHA.4144@TK2MSFTNGP02.phx.gbl: > >> We, for one, use this for code reusability, whereby all functions/subs >> that can throw an error will call a global error message handler that >> logs the message for troubleshooting when things goes wrong. Can't >> always rely on the user to give us the details of the error. With >> this we know where and when the error occurred. > > Use Exceptions - you can get a full call stack... My intention is make error handler re-usable and generic.
Thanks. BRAHM "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> escreveu na mensagem You found your answer, but I am always curious why somebody needs this kindnews:%23VMQe9VgGHA.3984@TK2MSFTNGP02.phx.gbl... Brahm, of information, while he is in fact in the sub? Cor Show quoteHide quote "Brahm" <daniel.br***@contronic.com.br> schreef in bericht news:O9gn43PgGHA.4708@TK2MSFTNGP04.phx.gbl... > Hey Guys! > > is there anyway to get in runtime current function or sub name ? > > Daniel > >
VB.NET events creates a hidden delegate, but how do I access it?
Console app no accessible 'Main' method with an app... CurrencyManager Question How to use the httpwebrequest with Cookies in "GET" method Overnight processes why are there still COM controls in VS.Net 2005? Convert VBScript to Visual Basic .Net LockWindowUpdate VB 2005 datagridview cell - get row/column info for updating data- how? Converting IP Address as string to MyIP as IPAddress |
|||||||||||||||||||||||