Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Blogs / DaxGeek / Demonstration: Debugging a ...

Demonstration: Debugging a Try, Catch Statement

1. In the AOT, create a new Job.

2. Copy the following code to the new
Job.

3. Place a breakpoint on the Try statement.


4. Press F5 to compile and run the code. The debugger starts.


5. Press F10 to step over each line of code.


6. When the validateWrite() method fails, it throws an error exception.


7. The debugger then jumps to the Catch list, and the rest of the code in
the Try statement is not executed.


8. Step through the code to the end.


9. Note the error messages that are shown in the Infolog. The last two
messages were in the code in the job. However, the first three were
added during the validateWrite method.



 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
CustTable custTable;
try
{
custTable.AccountNum = "0002";
custTable.CustGroup = "20";
if (!custTable.validateWrite())
{
throw error("Record failed validation");
}
custTable.insert();
info("Record was inserted in database");
}
catch (Exception::error)
{
error("There was an error inserting the
record.");
}

Best Regards,
Hossein Karimi

Comments

*This post is locked for comments