RUDOLF_BOTHMA
7 years agoCommunity Hero
call stack on application exception not returning full stack
Hi all,
I'm trying to improve the error handling of my scripting. Sometimes I have a try/catch in my code to handle some application exceptions e.g. trying to edit a readonly file
Current example:
function LogError() { try { LogErrorStack1(); } catch(e) { LogException(e,"Perhaps you should try that again"); } } function LogErrorStack1() { try { LogErrorStack2(); } catch(e) { throw e; } } function LogErrorStack2() { try { throw("test exception"); } catch(e) { throw e; } } function LogException(exception, additionalInformation) { Log.Error("An application exception was encountered: \n" + exception,additionalInformation); //More work for different exceptions }
I would expect the call stack to be LogException -> LogError -> LogErrorStack1 -> LogErrorStack2
Instead the stack ends at LogError:
It has missed out two of the functions in the call stack. Thoughts on how I can them displayed as well without logging on every tier of the call stack (LogErrorStack1 and LogErrorStack2 catches)?