meinTest
6 years agoOccasional Contributor
For JavaScript, I found the following workaround. Maybe it will help others.
I create a try-catch block. Within the try I provoke an exception, this one I catch-up with the catch and read-out the function name in the stack.
Note: this also works across several units -> USEUNIT
function getCaller(){ let arrStackLines = []; try{ throw new Error("throw a error to get the stack"); }catch(objE){ arrStackLines = objE.stack.split("\n"); } let strLine = arrStackLines[arrStackLines.length -1]; let intStart = strLine.indexOf("at ") + 3; let intEnd = strLine.indexOf("(<"); Log.Message(strLine.substring(intStart, intEnd)); }
Best regards
meinTest GmbH
SmartBear preferred value-added Service
Provider in the DACH region
Related Content
- 10 years ago
- 7 years ago
- 9 years ago