Catching NAV errors within NAS

tuthtuth Member Posts: 9
I've written a system which posts POs via an MSMQ adater into NAV.

On the occasions that NAV throws an error, I can't find a way to trap its description and pop a response message back on the queue and exit gracefully.

Any pointers would be greatfully received.

Thanks in advance.

Comments

  • DenSterDenSter Member Posts: 8,304
    Codeunits return a boolean, which means it completed successful or not. If you do CODEUNIT.RUN it will simply error out and you don't have control. BUT, if you catch the return value, you can program for either case:
    IF CODEUNIT.RUN THEN BEGIN
      // program what happens when it succeeds
    END ELSE BEGIN
      // program the failure message to MSMQ
      // use GETLASTERRORTEXT to get the actual error message
    END;
    
  • nunomaianunomaia Member Posts: 1,153
    DenSter wrote:
    Codeunits return a boolean, which means it completed successful or not. If you do CODEUNIT.RUN it will simply error out and you don't have control. BUT, if you catch the return value, you can program for either case:
    IF CODEUNIT.RUN THEN BEGIN
      // program what happens when it succeeds
    END ELSE BEGIN
      // program the failure message to MSMQ
      // use GETLASTERRORTEXT to get the actual error message
    END;
    

    This is one of the most marvelous functions implemented in NAV 5.0 client. It should solve your problems related to logging and displaying error messages in MSMQ.
    Nuno Maia

    Freelance Dynamics AX
    Blog : http://axnmaia.wordpress.com/
  • tuthtuth Member Posts: 9
    Thanks guys - a full night of sleep now awaits.
Sign In or Register to comment.