Dynamics 365 Business Central: View the actual error message in the debugger

Dynamics 365 Business Central

Hi, Readers.
Today I would like to share a mini tip when debugging in VS Code, viewing the error message in the debugger.

The process of finding and correcting errors is called debugging. With Visual Studio Code and the AL Language extension you get an integrated debugger to help you inspect your code to verify that your application can run as expected. You start a debugging session by pressing F5. For more information about Debugging in Visual Studio Code, see Debugging.

So debugging will tell us “where it’s wrong”.

And the error message on the page will tell us “what’s wrong”.

You cannot change Item Tracking Code because there are one or more ledger entries for this item.

Taking that error message above as an example, we can find the content of Text007 to see the actual error message.

This is not very convenient. And in Business Central, there are some standard methods that does not need to define error messages. For example, Record.TestField(Any, Code) Method.

Item Tracking Code must have a value in Item: No.=1896-S. It cannot be zero or empty.

So, is there an easy way to see the actual error message directly in Debugging?

Yes, there is actually a very simple way, which I only recently noticed.😑

When the debugger breaks on the error, just expand Locals in the debugger, then you can see the error message in _ALException.

Another example:

Is it very simple? Give it a try!!!

Find more about Debugging in MS Docs.


Hope this will help.

Thanks for reading.



Copied title and URL