Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generically Reference Function Name

Status
Not open for further replies.

maxhugen

Programmer
May 25, 2004
498
AU
I'm adding some error (exception) handling to javascript functions, and I'm wondering if there is a way to get the name of the function you're in? eg:

Code:
function testError() {
    try {
        ..... 
    } catch(e) {
        var func_name = "testError()";
        alert("myWebApp_name - Javascript Error\n\n" + 
              "Webpage: " + location.pathname.substring(location.pathname.lastIndexOf('/') + 1) + "\n" +
              "Function: " + func_name + "\n\n" + 
              "Error Name: " + e.name + "\n" + 
              "Error Message: " + e.message);
    }        
}
As you can see, I've had to manually set the function name to the variable 'func_name'. It would be cool if I could refer to the function generically somehow.

Does anyone know if this is possible please?

Max Hugen
Australia
 
Take a look at the response from BillyRayPreachersSon here: thread216-1209619.

----
 
Excellent! Thanks for the pointer.

Max Hugen
Australia
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top