Home » Microsoft » MB6-704 » Which code segment should you insert at line 10?
You have a job that contains the following X++ code: (Line numbers are included for reference only.)
You need to identify which code must be inserted at line 10 to ensure that line 12 executes.
Which code segment should you insert at line 10?
A. Catch (exception::error)
B. Catch (exception::warning)
C. Catch (exception::sequence)
D. Catch (exception::numeric)
Correct Answer: D
Explanation/Reference:
A numeric exception is thrown when a problem occurs during the use of any numerical function as is clearly the case in this code sample.
Note:
In X++, an exception is represented by a value of the enum named Exception. A frequently thrown exception is Exception::error enumeration value.
The catch statements are processed in the same sequence that they appear in the X++ code. It is common to have the first catch statement handle the Exception::Error enumeration value.
One strategy is to have the last catch statement leave the exception type unspecified. This means it handles all exceptions that are not handled by a previous catch. This strategy is appropriate for the outermost try catch blocks.
X++ try { /* Code here. */ } catch (Exception::Numeric) { info("Caught a Numeric exception."); } catch { info("Caught an exception."); }
Reference: Exception Handling with try and catch Keywords [AX 2012]