This trick is probably the first every X++ developer learns, so it deserves to be the first on the list of X++ Debugging Tips and Tricks.

Suppose an X++ exception occurs and you want to know why. The error is written to the Infolog. Double-clicking the line in the Infolog window will bring you to the line that threw the exception. Sometimes it is trivial to see the cause just by looking at the code. Other times it is not, and you will need the entire context including the call stack and variables to figure out what the cause is.

Set a breakpoint in the add method on the Info class – and rerun the scenario. When the exception is thrown your breakpoint is hit, and you can perform the autopsy.

Debug-trick-1_thumb1

This post is provided AS-IS, and confers no rights or warranties.