//Try Catch in ax 2012 X++
-->getting info in Messsage log
str msg;
int currentLine;
//Info log collection meesage
for (currentLine = startLine + 1; currentLine <= infolog.line(); currentLine++)
{
msg += infolog.text(currentLine);
}
-->To get only the last message you can use a code like this:
str msg;
if (infolog.line() > startLine)
{
msg = infolog.text();
}
static void TryCatchJob(Args _args)
{
System.Exception ex;
;
try
{
info("Check Catch block");
throw Global::error("Written to the Infolog.");
}
catch (Exception::Error)
{
ex = CLRInterop::getLastException();
//ex.get_Message(); // Whole Message collection
info(strFmt("Exception message %1",ex.ToString()));
//infolog.text(infologLine());
}
//like Warning/CLR error/ Dead lock/Update conflict/
}
https://msdn.microsoft.com/en-us/library/aa893385.aspx
https://community.dynamics.com/ax/b/klaasdeforche/archive/2011/08/09/try-catch-example-code
-->getting info in Messsage log
str msg;
int currentLine;
//Info log collection meesage
for (currentLine = startLine + 1; currentLine <= infolog.line(); currentLine++)
{
msg += infolog.text(currentLine);
}
-->To get only the last message you can use a code like this:
str msg;
if (infolog.line() > startLine)
{
msg = infolog.text();
}
static void TryCatchJob(Args _args)
{
System.Exception ex;
;
try
{
info("Check Catch block");
throw Global::error("Written to the Infolog.");
}
catch (Exception::Error)
{
ex = CLRInterop::getLastException();
//ex.get_Message(); // Whole Message collection
info(strFmt("Exception message %1",ex.ToString()));
//infolog.text(infologLine());
}
//like Warning/CLR error/ Dead lock/Update conflict/
}
https://msdn.microsoft.com/en-us/library/aa893385.aspx
https://community.dynamics.com/ax/b/klaasdeforche/archive/2011/08/09/try-catch-example-code
No comments:
Post a Comment