例外処理について

こんばんは
UiPath Studio 2025.0.176STS Community editionのユーザーです。

例外処理について2点ご教示ください。

[前提]
Excelを読んで、データテーブルdtを取得し、下記のコードでDataRow変数dr_TransactionItemを抽出して、DataRow変数を1件ずつ処理するコードを作成中です。

dr_TransactionItem=dt.Rows(int_TransactionNumber)

Main.xaml全体をTryCatchアクティビティで囲んであり、Tryブロックで例外が発生したらCatchブロックで受けてログを記録して「ワークフローを終了」アクティビティで、ワークフローを終了させます。

[質問1]

INPUTファイルの存否チェックをワークフローの冒頭で実施しています。(下図参照)
「INPUTファイルの存否チェック」シーケンスはTryCatchアクティビティで囲んであります。
「INPUTファイルの存否チェック」シーケンスで例外が発生した場合、「INPUTファイルの存否チェック」を
囲んでいるTryCatchのCatchブロックで例外処理をした方が良いでしょうか。それとも、このCatchブロックでは再スローして、上位の
Catchブロックで例外処理をした方が良いでしょうか。

[質問2]

「1件分の業務処理」シーケンスで1件分のDataRow処理をしています。(下図参照)
「1件分の業務処理」シーケンスはTryCatchアクティビティで囲んであります。
「1件分の業務処理」シーケンスで例外が発生した場合、ワークフロー実行を継続して次のDataRow処理に進みたいため、「1件分の業務処理」シーケンスを囲んでいるTryCatchのCatchブロックでは、再スローをしないでCatchブロック内で例外処理をした方が良いという認識ですが、合っていますでしょうか。

namaste @gorby Q1 If the error means the whole workflow cannot continue or either handle it locally with termination or rethrow so the top-level Catch ends the workflow consistently.

For Q2 surround the One Business Process sequence with a TryCatch and in the Catch block, log the error and move on to the next DataRow and do not rethrow here otherwise the exception will bubble up to the top-level TryCatch and stop everything.

Cheers

Hello @gorby

  1. INPUT File Check:- If the input file is missing, the process cannot continue, so catch the error, ‘log it’, then rethrow to the global Catch block to terminate the workflow cleanly.

  2. One Business Process (Single DataRow):- Handle locally, do NOT Rethrow. If processing ‘one row’ fails, ‘log the error’ and continue with the next row so the workflow keeps running without stopping.

Hey, exemplary Ashoka mind@bhavesh.choubey,
Your feedback affirmed my thinking and gave me reassurance.

While cleaning up my newly purchased e-VITARA.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.