The following static method can be used to decode a .NET exception:
static void cRLExtendException(System.Exception _exception) { System.Exception exception = _exception; SysInfoLogStr infoLogStr; ; if (exception) { infoLogStr = exception.get_Message(); if (exception.Equals(exception.GetBaseException())) { // the most inner exception has reached, now we can write the infolog message and throw the exception error(infoLogStr); throw Exception::CLRError; } else { // the current exception is not the most inner exception, so we just set a infolog prefix setprefix(infoLogStr); MyClass::cRLExtendException(exception.get_InnerException()); } } /* else { well, there was no CLR exception, so just left out } */ }
And that's how to use it:
System.String[] files; ; try { files = System.IO.Directory::GetFiles('c:\\halliGalli'); } catch { MyClass::cRLExtendException(CLRInterop::getLastException()); }Now your infolog window will look like this:
In this case the auxiliary method is hosted on a class named 'MyClass'. Where the method should be implemented on your environment has to be decided by you or your team.
Thank you for this article! It was useful for me.
ReplyDelete