I am writing a wrapper for SSHnet dll
from renci (https://sshnet.codeplex.com/), so I can fetch files from a sFTP
server via Dynamics AX periodically.
When I catch errors in C#
project for example in a try catch statement how can I parse the error message back to AX?
Options I thought of;
Should I put the error message in a string variable and read the string
in Dynamics AX?
Write errors to the event log on the AOS / client?
The easiest way to pass error to AX is a rethrow it in C#
catch (Exception ex)
{
// Do special cleanup, logging etc.
throw;
}
and catch it in AX
catch (Exception::CLRError)
{
ex = ClrInterop::getLastException();
if (ex != null)
{
ex = ex.get_InnerException();
if (ex != null)
{
error(ex.ToString());
}
}
}