Exception handling

Throughout the book, we have raised many exceptions through the throw command, but so far, we have simply allowed this exception to fall through the code, giving our user an error.

This is fine for many cases, but sometimes, we need specific handling. This is especially important when the error is a number of classes deep, and could produce an error message that makes no sense to the user. We may, in these cases, need to provide some context for the message or a different, more useful message for the user.

Handling general exceptions

In the previous section, an error could have been produced in many places, none of which are useful to the user. They are useful to the administrator or developer.

Looking at the code the errors we ...

Get Mastering Microsoft Dynamics AX 2012 R3 Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.