0

I have an external application that writes to the general journal. When an error occurs it just has a basic description "error validating record" for example. I would also like to return the warning message as it is more detailed. Problem is i don't know how to catch the warning message in code and return it with the error back to my 3rd party app. So i ended up catching the error and then querying the sys exception table. But the issue seems to be a delay now. Which means it doesn't write the error/warning to the table until the aif service is completely out. So it will always return the last error instead of the current error. See code below. IF there is a better solution to get the warning returned let me know. i have looked around and nothing seemed to work.

 catch (Exception::Error)
              {
select maxOf(createdDateTime) from sysExceptionTable where sysExceptionTable.Exception==Exception::Warning && (sysExceptionTable.createdBy=='username' || sysExceptionTable.createdBy=='username');
                  select description from sysExceptionTable2 where sysExceptionTable2.Exception==Exception::Error && (sysExceptionTable2.createdBy=='username' || sysExceptionTable2.createdBy=='username') && sysExceptionTable2.CreatedDateTime==sysExceptionTable.createdDateTime;
                  errorMsg=sysExceptionTable2.Description;

                  select description from sysExceptionTable2 where sysExceptionTable2.Exception==Exception::Warning && (sysExceptionTable2.createdBy=='username' || sysExceptionTable2.createdBy=='username') && sysExceptionTable2.CreatedDateTime==sysExceptionTable.createdDateTime;

                  errorMsg=errorMsg + " " + sysExceptionTable2.Description;


                 throw Global::error(errorMsg);
         }
Sirus
  • 382
  • 1
  • 8
  • 35
  • 1
    Take a look at the following links: [Ax 2012 aif catching warnings](http://stackoverflow.com/questions/40793797/ax-2012-aif-catching-warnings), [Can't catch exception inside AIF service](http://stackoverflow.com/questions/17830973/cant-catch-exception-inside-aif-service), [catching the warning message from aif web service](http://stackoverflow.com/questions/42587796/catching-the-warning-message-from-aif-web-service), [How to get meaningfull error messages from AIF](https://community.dynamics.com/ax/f/33/t/35246) and [link](http://axdevnotes.blogspot.de/2011/06/aif-exception-message.html?m=1) – FH-Inway Apr 11 '17 at 16:28

1 Answers1

0

Your question is a little hard to follow, but it sounds like you're trying to catch the error thrown by your 3rd party app, but since you don't know how to do it, you're looking at the AIF exceptions?

Have you tried:

catch
{
    throw error(AifUtil::getClrErrorMessage());
}

And AifExceptionsView might be of use to you.

Alex Kwitny
  • 11,211
  • 2
  • 49
  • 71