Page 1 of 1

Get Method Name?

PostPosted: Thu Jul 23, 2009 9:39 pm
by chico
I want to get better information on our error logs, specifically, be able to get the name of the method (if any) that was running when the error occured.

Is there a command, plugin, tool, wish... anything you can do to grab the name of the currently active method?

Thanks,

chico

Re: Get Method Name?

PostPosted: Mon Aug 03, 2009 10:53 am
by jcompagner
at what point do you want to get that info?
like in a try/catch?

But if you have the try/catch then you already know the method you are in.

Re: Get Method Name?

PostPosted: Thu Feb 25, 2016 12:01 pm
by juan.cristobo
I'd like to get the method name inside it, i.e.:
Code: Select all
function aMethod()
{
    application.output('The name of this method is:' + ????)
}


Of course, I know the method name now, but if I change it, I have to remember to change the code too.

Re: Get Method Name?

PostPosted: Thu Feb 25, 2016 6:43 pm
by steve1376656734
Hi Juan,

I use the following code to get both the form name and method name:
Code: Select all
   /** @type {String} */
   var methodName = controller.getName() + "." + arguments['callee'].name;


but just the last part will give you the method name on it's own.

Hope this helps
Steve

Re: Get Method Name?

PostPosted: Thu Feb 25, 2016 6:58 pm
by juan.cristobo
Thanks, Steve, I found that code, but Servoy shows a warning:
Code: Select all
Event parameter is passed to event method; make sure it is used with right type (change method signature).

So I don't know if that code is a good practice :wink:

Re: Get Method Name?

PostPosted: Thu Feb 25, 2016 7:09 pm
by steve1376656734
That's odd as I definitely don't get that warning - I am running Servoy 7.4.6