Wiki source code of Fehlerbehandlung


Show last authors
1 {{content/}}
2
3 When everything works out smoothly, each action completes normally and the workflow is successful. Unfortunately, errors may always happen occassionally, such as when the internet connection is not working, when the server does not have any empty memory left, or when an external service is not available. When you designer a workflow, you should always consider which errors may happen and how you wish to proceed in case they do happen.
4
5 This help page explains what happens when an error occurs in the workflow and how you can react to errors.
6
7 == Error types
8
9 {{figure image="workflow_errorhandling_info_dialog_en.png"}}
10 The info windows shows a list of all possible errors that may occur when the action is executed.
11 {{/figure}}
12
13 With very few exceptions, every action can result in an error. Each action can result in different kind of errors. If you want to learn which error can occur, click on the {{ficon name="information-outline"/}} icon to the top right of an action. This open an info window which shows all possible kinds of errors. Errors are categorized into two different types:
14
15 * Hard errors, which are displayed in red. A hard error usually indicates a technical issue, such as a missing internet connection.
16 * Soft errors, which are displayed in orange. A soft error usually indicates an issue in the business logic, such as when you access a non-required upload field, but no file was uploaded for that upload field.
17
18 For each error, the info window shows the corresponding error code. Hover over the error code to view a short explanation when that error may occur. Later in the workflow, you can use variables to check which kind of error occurred.
19
20 In addition to the error codes specific to each action, the following error codes also exist:
21
22 ; GENERAL
23 : This error code is used when an unexpected error occurred during an action, which was not converted into a custom error code by the action itself. This may indicate a programming error, bad data or a severe server issue.
24 ; HANDLER_NOT_FOUND
25 : This error is used when the processing logic of an action could not be found. Usually this happens when the workflow contains an action provided by a plugin; and that plugin was either uninstalled or is currently deactivated.
26
27 When an error did occur, additional data may be provided by the action with further details regarding the error. Which data is provided depends on the action and the error code. Refer to the info window, which shows all data items for each error code. For example, the [[HTTP request action>>Formcycle.Designer.Workflow.Actions.HttpRequest]] lets you access the response code and response message when an error with the code //SERVER_ERROR// or //CLIENT_ERROR// occurred.
28
29 == Error case behavior
30
31 {{figure image="workflow_errorhandling_trycatch_en.png" clear="h1"}}
32 Handling errors with an error block. Here, an email is sent to an administrator and the state of the form record is set to //Error//.
33 {{/figure}}
34
35 {{figure image="workflow_errorhandling_errorevent_en.png" clear="h1"}}
36 Handling errors with an error event. Here, an email is sent to an administrator and the state of the form record is set to //Error//.
37 {{/figure}}
38
39 {{figure image="workflow_errorhandling_softerror_en.png" clear="h1"}}
40 Handling soft errors with a condition. Here, we check whether a soft error with the code //CLIENT_ERROR// occurred. If it did, an email is sent to an administrator and the state of the form record is set to //Error//.
41 {{/figure}}
42
43 It is important to understand what happens when an error occurred in the workflow. You need to distinguish between soft and hart errors. The following section briefly explains the behavior of the workflow in case of an error.
44
45 === Hard errors
46
47 When an action ends abruptly with a hard error, the action is aborted and a [[protocol entry>>Formcycle.UserInterface.Protocol]] with the result //Error// is created. The protocol entry contains the error code as well as additional info regarding the error. If you did not explicitly set up an error handler, the entire processing chain of the current event is aborted and no more actions are executed. All queued events that would have been executed after the current event are aborted as well; and the entire workflow execution ends in an error. If the workflow was started in response to a user submitting a form, the user is shown the [[generic error page template>>Formcycle.UserInterface.FilesAndTemplates.HTML]]. If this is not the desired behavior, you can react to an error in one of the following two ways:
48
49 First of all, you can add an [[error handler block>>Formcycle.Designer.Workflow.FlowControl.HandleErrors]] to the workflow. The error block catches all errors that did occur in one of the actions inside the default section on the left-hand side of the error block. Then, if an error did occur, the error block runs the actions in the error branch on the right-hand side of the error block. This way, you can prevent the workflow from getting aborted. Once you have handled an error with an error block, the workflow proceeds with the next action after the error block. Note that in case one of the actions in the error branch of the error block should end in an error, the workflow will be aborted. You can nest error block in case you need to handle errors in the error branch of an error block. Error blocks are useful when you wish to handle a specific error of a certain action, such as when a HTTP requests results in a client error.
50
51 Secondly, you can also handle errors via a so-called [[error event>>Formcycle.Designer.Workflow.Events.WorkflowError]]. An error event occurs when a processing chain ends in an unhandled error that would result in the workflow getting aborted. In particular, this means that an error event **does not** occur when you have already handled an error by means of an error block. Once the processing chain of an error event was processed successfully, the workflow as a whole is considered to have been successful. When a workflow contains more than one error event, each processing chain is processed in order, from left to right. In case the processing chain of an error block ends in an unhandled error, the workflow is aborted and no more error events are processed. Error events are useful when you wish to run a general action in case of an error, such as sending an email to an administrator.
52
53 === Soft errors
54
55 When a soft error occurs, the action is still treated as having been completed successfully. The workflow proceeds with the next action, as if no error had occured. In particular, this means that error block and error events are not processed when a soft error occurs.
56
57 In this sense, you can also think of soft errors as warnings that may inform about potential issues about an action. Note that an action can produce more than one soft errror. When an action produces at least one soft error, a [[protocol entry>>Formcycle.UserInterface.Protocol]] with the result //Warning// is created that contains the error code of each soft error, as well as further informtation about each soft error. You can use the variable //[%$ActionName.HAS_SOFT_ERROR]// to check whether any soft errors did occur. Alternatively, you can use the variable //[%$ActionName.SUCCESS]// if you are only interested whether a hard of soft error occured.
58
59 == Variables
60
61 You can use of the available [[variables>>Formcycle.UserInterface.Variables]] to check which error occured. The following list contains all error-related variables.
62
63 ; [%$ActionName.SUCCESS%]
64 : Either //true// or //false//. Indicates whether an action was successful, i.e. whether neither a hard nor a soft error occured. Usually this variable should suffice, but in case you need to distinguish between soft and hard errors, you can use one of the following variables:
65 ; [%$ActionName.HAS_HARD_ERROR%]
66 : Evaluates to //true// when the action resulted in a hard error; or //false// otherwise. Hard errors need to be handled explicitly, such as with an error block or error event, and will result in the workflow getting aborted in case they are not handled.
67 ; [%$ActionName.HAS_SOFT_ERROR%]
68 : Evaluates to //true// when the action produced one or more soft error; and //false// otherwise. A soft error is similar to a warning, the workflow proceeds as normal even if a soft error occurs.
69 ; [%$ActionName.SOFT_ERRORS%]
70 : A list with all soft errors that were produced by an action. //[%$Aktionsname.SOFT_ERRORS[0]%]// is the first soft error, //[%$Aktionsname.SOFT_ERRORS[1]%]// is the second soft error, and so on. For each soft error, you can access its //code// (error code), its //message// (error message) and its //data// (additional errror data). For example, //[%$Aktionsname.SOFT_ERRORS[2].message%]// evaluates to the error message of the third soft error, if there are at least three soft errors. To access the number of soft errors, use //[%$Aktionsname.SOFT_ERRORS.length()%]//.
71 ; [%$ActionName.ERROR_CODE%]
72 : Evaluates to the error code, in case an action ended in a hard or soft error. When more that one error was produced by an action, evalutes to the error code of the first soft error. For example, the [[HTTP request action>>Formcycle.Designer.Workflow.Actions.HttpRequest]] may result in the error codes //CLIENT_ERROR// and //SERVER_ERROR//.
73 ; [%$ActionName.ERROR_MESSAGE%]
74 : Evaluates to the error message, in case an action ended in a hard or soft error. When more that one error was produced by an action, evalutes to the error message of the first soft error. The error message is usually a short English phrase or sentence that provides further details about the error.
75 ; [%$ActionName.ERROR%]
76 : Evaluates to the additional data provided by the error, in case an action ended in a hard or soft error. When more that one error was produced by an action, evalutes to the error data of the first soft error. Which data is available depends on the action and the error code. Refer to the info window of an action for a list of data provided for each error code. For example, the //HTTP request// action lets you access the response code via the variable //[%$ActionName.ERROR.responseCode%]//, in case the action ended with the error code //SERVER_ERROR// or //CLIENT_ERROR//.
77 ; [%$LAST_ERROR_CODE%], [%$LAST_ERROR_MESSAGE%] and [%$LAST_ERROR%]
78 : Evaluates to the error code, message, or additional error data of the most recent hard error. This is especially useful when used inside an error block, as it lets you access the error without having to refer to the name of a particular action. You can also use this variable within an error event.
79 ; [%$LAST_ERROR_NODE_NAME%] and [%$LAST_ERROR_NODE_TYPE%]
80 : Evaluates to the name and technical type of the most recent action that resulted in a hard error.