Wednesday, March 4, 2026

Error readable from string in D365FO

 Reference class: RetailSyncOrdersSchedulerTask

Error readable:

private str generateHumanReadableErrorDetail(System.Exception _exception, str _errorDetail = '')

{

    str errorDetail, exceptionType, stackTrace, exceptionMessage;


    errorDetail = _errorDetail;

    // When the CLR error encounters it gets the inner exception message, call stack and stores in Database.

    if (_exception && _exception.InnerException)

    {

        if (_exception.InnerException.InnerException && _exception.InnerException.StackTrace)

        {

            // Use inner exception if it is available as it is often more descriptive.

            errorDetail = errorDetail ? errorDetail +

                        _exception.InnerException.InnerException.Message : _exception.InnerException.InnerException.Message +

                         _exception.InnerException.StackTrace.ToString();

        }

        else if (_exception.InnerException.StackTrace)

        {

            errorDetail = _exception.InnerException.Message +  _exception.InnerException.StackTrace.ToString();

        }

        else

        {

            // When the exeption not returns a call stack, we get the call stack from the <c>Xsession<c> object.

            errorDetail = _exception.InnerException.Message + con2str(xSession::xppCallStack());

        }

    }


    return errorDetail;

}

Error readable from string in D365FO

 Reference class: RetailSyncOrdersSchedulerTask Error readable: private str generateHumanReadableErrorDetail(System.Exception _exception, st...