MapForce provides support for the definition of exceptions. You can define the condition that will throw an error. When the condition is satisfied, a user-defined message appears and the mapping process is stopped. The ExpenseLimit.mfd file in the ...\MapForceExamples folder is a sample mapping that contains an exception function.
To insert an exception component:
•Select the menu option Insert | Exception, or click the Exception icon in the icon bar.
The example above shows how exceptions are defined in mappings. The exception should be triggered when the expense limit is exceeded, i.e. higher than 200 in this example.
•The less component checks to see if expense is less than 200 with the bool result being passed on to the filter component.
•When the bool result is false, i.e. expense is greater than, or equal to, 200, the on-false parameter of the filter component activates the exception and the mapping process is stopped. (Note that you can also connect the exception to the on-true parameter, if that is what you need.)
•The error text (Expense limit exceeded!) supplied by the constant component is mapped to the error-text parameter of the exception function.
•The error text appears in the Output tab, and also when running the compiled code.
It is very important to note the filter placement in the example:
•Both parameters of the filter component, on-true and on-false, must be mapped! One of them needs to be mapped to the exception component, and the other, to the target component that receives the filtered source data. If this is not the case, the exception component will never be triggered.
•The exception and target components must be directly connected to the filter component. Functions, or other components, may not be placed between the filter and either the exception, or target components.
•When generating XSLT 2.0 and XQuery code, an "Execution failed" error appears in the Messages window, and the respective XSLT2 or XQuery tab is opened with the error line automatically highlighted.
© 2014 Altova GmbH