Googleアナリティクス

2018年7月3日火曜日

Try-Catch-Finally Patter in LogicApps/Flow

Original Post is here.

In Logic Apps and Flow, patterns for error handling are available. For those who write the program, it is a familiar Try-Catch-Finally format.

In order to test whether it is possible to make the expected movement, I will create a LogicFlow like the following.

image

As described above, prepare the Try, Catch, Finally using the scope. First we create the appropriate variables, but we will also use them to generate errors later.

image

Next, set up catch. Since you can set the execution condition by clicking the right end, check "Fail" and "Time out" and remove others. By setting like this, it is possible to deal with cases where the processing does not end normally. In some cases, it may be good to set "skip", but here it is divided depending on whether skipping occurs in Try.

image

Next is Finally. This is the part that always executes regardless of the processing so far. Therefore, as execution conditions, check "Success", "Failure", "Skip", "Timeout" all.

image

Let's execute it so that it becomes a normal pattern. To enable processing in Try to work properly, we have set up things that work without problems, such as adding 1 to the variable.

image

As you can see, Try and Finally are executed, and Catch is skipped. This is the flow during normal processing.

image

Errors are intentionally generated by processing. By using the function as described above, it is possible to intentionally generate an error.

image

When executed, the function becomes an error in Try, Catch is executed, and Finally is also executed. In Catch, I think that processing such as when such an error occurred, such as correction, will be done.

image

Finally, try to generate an error even in Catch. As mentioned above, errors occur in the Try part and Catch, respectively, but Finally is implemented without problems.

image

LogicFlow can be executed in this way, but one caution is necessary. Even if an error occurs, the processing result of LogicFlow will be "Succeeded" as it is. Therefore, in each section, it is necessary to set the status of whether processing has ended in a variable, and finally return whether it is success or failure with that value.

Of course, it is sometimes acceptable for this part to be successful even if an error occurs in the middle. Please change it as necessary and use it.

0 件のコメント:

コメントを投稿