|Available in: Logi Info|| Source code name: IfError|
IfError helps handle errors while running Procedures. Errors include events such as failure to update a database, run a report, save a file. Without IfError elements, the system returns an error page detailing the original error.
Add Procedure and Response elements under the IfError to perform error-handling work.
IfErrors can be added at the Procedure, Task, and Process levels, and all three. Errors "bubble up" until an IfError is found. If a Procedure fails, and that Procedure does not have its own child IfError element, the system looks up at the Task element for an IfError. If not found, the top level Process element is checked.
When bubbling up, once a Procedure's IfError has already been used, it will not be re-used, thus preventing the possibility of infinite loops.
If there are no Response elements under an IfError, execution resumes with the element following the failed procedure. Thus an error can be completely ignored by not adding any child elements below the IfError.
You may include error handling within error handling. An error might occur in a Procedure under an IfError. You may have additional IfError elements under that Procedure. Otherwise, the error will bubble-up to the Task and Process levels.
In order to perform different actions based on different errors, IfError has an ErrorFilter attribute. Add an IfError for each different type of error. The server looks for the first IfError that matches the current error. Usually the last IfError should have a blank ErrorFilter to catch left-over errors.
There are two ways to get error message text. For a specific Procedure, use "@Procedure.ProceduredID.ErrorMessage~". (Replace "ProcedureID" with the ID of the Procedure that failed.) For any procedure, use "@Function.LastErrorMessage~".