Quantcast
Channel: Microsoft Dynamics NAV
Viewing all articles
Browse latest Browse all 64865

Forum Post: RE: Change in code unit error handling with 2013 R2?

$
0
0

So, after weeks of research, banging my head on rocks, walking around in circles counter clockwise, I finally figured it out.

Short answer is that NAV 2013 R2 requires that you handle exceptions. ERROR exceptions can be thrown, but they have to be 'caught'. AND the referenced .NET code cannot throw unhandled exceptions. Any unhandled exceptions will halt the NAS.

In the CAL code, we had to move a bunch of code around, pushing it down an additional layer. To correctly catch the exception, the code executes in the OnRun method of our new units. It's OK to throw an exception here as long as the calling method catches that error; like this:

IF NOT SomeCodeUnit.RUN THEN BEGIN

    SomeText := GETLASTERRORTEXT();

    CLEARLASTERROR();

    HandThisErrorToDotNet(SomeText);

END;

Where SomeCodeUnit can throw ERROR until the cows come home. 

Hope this helps future NAVrs. 


Viewing all articles
Browse latest Browse all 64865

Trending Articles