C/AL rollback without error
If you want to rollback the database changes, but do not want the code execution to end, simply call ASSERTERROR ERROR(''); The ERROR('') will quietly rollback the data changes, and…
If you want to rollback the database changes, but do not want the code execution to end, simply call ASSERTERROR ERROR(''); The ERROR('') will quietly rollback the data changes, and…
Did I CATCH your attention yet? At least I did TRY.
Now that I have completed my series on exception handling in C/AL, a very valid question pops up: why don’t we have try..catch syntactical constructs in C/AL, the way we have it in other programming languages?
Good. At this point we know everything about exception types, what they are, how to obtain them, how to compare them (at least directly). All of these have suddenly become relevant now that we have GETLASTERROROBJECT function in NAV 2015.
But an old friend is still around, the GETLASTERRORCODE function, what about it? Why do we need to bother with GETLASTERROROBJECT when we have a simpler approach, with less peeking into inner exceptions, less reflection, less spooky, obscure .NET internals?
To continue my series about exception handling in NAV, this time I’ll discuss how to gain insight into exceptions in NAV. As I mentioned already, the GETLASTERROROBJECT function gives you an instance of System.Exception, actually of a class descending from it, which allows you to get more information about the context of the error that has just happened.
Yesterday, thanks to @sforkmann and his blog at navision-blog.de, I have learned of the existence of Statical Prism. I’ve given it a try today, and I am pretty happy –…