Generic try catch example, which will give detailed information about error can be used in AX 2012 as well as D365 for operations.
try
{
}
catch (Exception::CLRError)
{
ex = ClrInterop::getLastException();
if (ex != null)
{
ex = ex.get_InnerException();
if (ex != null)
{
error(ex.ToString());
}
}
}
catch (Exception::Error)
{
info(ppAutoInventRegister::getErrorStr());
}
public static server str
getErrorStr()
{
SysInfologEnumerator enumerator;
SysInfologMessageStruct msgStruct;
Exception exception;
str error;
enumerator
= SysInfologEnumerator::newData(infolog.cut());
while (enumerator.moveNext())
{
msgStruct = new SysInfologMessageStruct(enumerator.currentMessage());
exception =
enumerator.currentException();
error = strfmt("%1 %2", error, msgStruct.message());
}
return error;
}
No comments:
Post a Comment