log user error()
If this function has been called at least once, the profile is terminated with an error after the end of phase 3 (mapping). If the function is called more than 150 times, processing is terminated even before the end of phase 3.
Error jobs marked as faulty with this function are displayed in the Control Center under "Logs/Errors" with an exclamation mark! before the profile name.
Errors of this type can be viewed and edited in a special way in the Control Center. There, the user-defined error message b or c is displayed (this message is also returned as a result of the function execution). The error message can optionally be directly specified in parameter b or read from the replacement file ./conf/user_errors.properties with the key in c. If there is a message in the file for key c, it is used, otherwise the message in parameter b.
Parameter a is used for the internal marking of a source field (therefore only the parameter types "Source field" and "Link" are allowed). In the Control Center, the location corresponding to the marked source field is then displayed in the input file. The optional parameter d may contain the name of the source field - this shows the field more clearly in error handling and makes it easier to find.
Note: The purpose of this function is to abort a mapping if a source field has a value that is not allowed and to mark this source field internally so that the corresponding data in the input file can then be viewed and corrected in the Control Center. The function is therefore used in a function construct that previously checks the value of the source field and only executes this function here if an undesirable/problematic value is found in the source field.
Parameters
Parameter |
Description |
a |
Source field to be marked (parameter type Field or Link), otherwise the invalid value itself. |
b |
Error message to be logged. |
c |
(optional) Key for the replacement file. The file has to be in folder ./conf and must be named user_errors.properties. See the following example. See also parameter e. |
d |
(optional) Name of the source field if parameter a represents a value and not a source field. |
e |
(optional) Path to the replacement file. Default: ./conf/user_errors.properties |
Example
In the following input file (an order), we want to check whether an order contains a negative quantity.
9879871234,Peter Dunn,4,25-04-2017
9879871235,Max Keller,-5,24-04-2017
9879871236,Michael Peterson,7,08-02-1999
For this purpose, we check the quantity in the mapping (source fields Order_number, Customer_name, Quantity, Date). If the quantity is negative, we call the function log user error(a,b,[c]).
Assume the following replacement file user_errors.properties in folder ./conf
negative_amount=The quantity is negative!
date_in_past=The date is in the past!
Here are a few examples of what we would get for a function call as a result for various parameter values. Note: If you choose type Link for parameter a, the field on which the function is executed must, of course, be mapped to the source field Quantity.
Parameter a |
Parameter b |
Parameter c |
Parameter d |
Parameter e |
Result |
Field: Quantity |
|
negative_amount |
|
|
The quantity is negative! |
Field: Quantity |
The quantity is negative! |
|
|
|
The quantity is negative! |
Field: Quantity |
Processing error. |
date_in_past |
|
|
The date is in the past! |
Link |
Processing error. |
date_in_past |
|
|
The date is in the past! |
Link |
Processing error. |
non_existent_value |
|
|
Processing error. |
-100 |
Processing error. |
non_existent_value |
Quantity |
|
Processing error. |
For our example, we use the first parameter constellation. We specify the source field Quantity in parameter a. That means that the function will mark the position of the data corresponding to this source field as faulty. This allows us, as we shall see below, to correct this data later in the Control Center.
If the function in our profile with the name Profile_with_function_log_user_error is called, the termination of the profile will be shown under "Logs/Overview" in the Control Center. The log messages will show the number of function calls: Defined user errors (1) detected - aborting means that the function has been called once (thus, one marking was made) and therefore the processing of the profile has been terminated after phase 3.
The abort will be displayed as follows in "Logs/Errors".
If you select this error entry (errors of this type are marked with an exclamation mark "!"), you can choose option "Edit errors" in the context menu. This opens a new dialogue.
(1) Error message: This is the list of all the markings made by the function (in our case one). If you select an entry in the list, specific data will be shown in (2) and (3).
(2) Window top right: Details about the target structure are displayed here. The target structure field on which the function was executed, the iteration of the target field's node when the marking happened, and the record in which it happened. Reminder: The function is executed on a target field to mark a source field (and consequently its corresponding input data).
(3) Window bottom: The input file is displayed here. If an entry in (1) is selected, the corresponding location in the input file will be highlighted. In our case -5 (i.e. the negative quantity detected as faulty).
(4) Save & restart job: f a file has been corrected, it can be saved (on the server). The job can then be restarted with this corrected file.