# 呼び出したワークフローのエラーをキャッチしたい

**URL:** <https://forum.uipath.com/t/topic/183465>\
**Category:** Ask in Your Language\
**Tags:** exception-handling, question, activities\
**Created:** [January 9, 2020, 5:01am UTC](https://forum.uipath.com/t/topic/183465 "2020-01-09T05:01:46Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![kana612](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kana612/32/179008_2.png) [@kana612](https://forum.uipath.com/u/kana612)\
**Post date:** [January 9, 2020, 5:01am UTC](https://forum.uipath.com/t/topic/183465/1 "2020-01-09T05:01:46Z")

</div>

Main.xamlのtrycatchのtry部で別のワークフロー（X.xaml）の呼び出しをしているのですが、  
X.xaml内でエラーが発生した場合、Main.xamlのCatches部の処理がされず終了してしまいます。  
仕様ですか？これを実現する方法はありますでしょうか…  
ご教授よろしくお願いいたします。

---

<div class="post-metadata">

**Author:** ![HANACCHI](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/hanacchi/32/85375_2.png) [@HANACCHI](https://forum.uipath.com/u/HANACCHI)\
**Post date:** [January 9, 2020, 5:08am UTC](https://forum.uipath.com/t/topic/183465/2 "2020-01-09T05:08:41Z")

</div>

Main.xamlのtrycatchのtry部のInvokeは成功しているので、Catchesでは捕捉できないと思います。

X.xaml内でエラーが発生した場合、ThrowアクティビティでMain.xamlのtrycatchに捕捉させるのが常套かと思います

---

<div class="post-metadata">

**Author:** ![Yoichi](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/yoichi/32/523754_2.png) [@Yoichi](https://forum.uipath.com/u/Yoichi)\
**Post date:** [January 9, 2020, 5:50am UTC](https://forum.uipath.com/t/topic/183465/3 "2020-01-09T05:50:48Z")

</div>

こんにちは

> [@kana612](#):
>
> X.xaml内でエラーが発生した場合、Main.xamlのCatches部の処理がされず終了してしまいます。  
> 仕様ですか？これを実現する方法はありますでしょうか…

通常はMain側で適切なExceptionのTypeを指定していればキャッチできるかと思いますが．．．  
X.xamlの内部でもtry-catch使っていて、そこで例外がつぶされているということはありませんでしょうか？

---

<div class="post-metadata">

**Author:** ![kana612](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kana612/32/179008_2.png) [@kana612](https://forum.uipath.com/u/kana612)\
**Post date:** [January 9, 2020, 6:02am UTC](https://forum.uipath.com/t/topic/183465/4 "2020-01-09T06:02:45Z")

</div>

> [@Yoichi](#):
>
> 通常はMain側で適切なExceptionのTypeを指定していればキャッチできるかと思いますが．．．  
> X.xamlの内部でもtry-catch使っていて、そこで例外がつぶされているということはありませんでしょうか？

System.Exceptionを選択しているのですができません。  
X.xaml内ではトライキャッチの使用はありません。

---

<div class="post-metadata">

**Author:** ![kana612](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kana612/32/179008_2.png) [@kana612](https://forum.uipath.com/u/kana612)\
**Post date:** [January 9, 2020, 6:04am UTC](https://forum.uipath.com/t/topic/183465/5 "2020-01-09T06:04:26Z")

</div>

> [@HANACCHI](#):
>
> X.xaml内でエラーが発生した場合、ThrowアクティビティでMain.xamlのtrycatchに捕捉させるのが常套かと思います

X.xaml内にもトライキャッチを置いて、try部に処理を、catches部にthrowアクティビティを置くという認識で合っていますか？（これでもうまくいきませんでした…）

---

<div class="post-metadata">

**Author:** ![cheez\_RPA](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/cheez_rpa/32/278069_2.png) [@cheez\_RPA](https://forum.uipath.com/u/cheez_RPA)\
**Post date:** [January 9, 2020, 6:36am UTC](https://forum.uipath.com/t/topic/183465/6 "2020-01-09T06:36:33Z")

</div>

X.xaml を単体で実行した場合、あるいは Main.xaml 内で Try-catch 内に含めずに Invoke Workflow File を実行した場合に、例外は発生しますか？

---

<div class="post-metadata">

**Author:** ![HANACCHI](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/hanacchi/32/85375_2.png) [@HANACCHI](https://forum.uipath.com/u/HANACCHI)\
**Post date:** [January 9, 2020, 6:46am UTC](https://forum.uipath.com/t/topic/183465/7 "2020-01-09T06:46:05Z")

</div>

[呼び出したワークフローのエラーをキャッチしたい.zip](https://forum.uipath.com/uploads/short-url/bN0pPErUkiTVTd6aqNrXXZAnTGH.zip) (12.0 キロバイト)

X.xamlで、英文字をInteger.Parseさせてみたところ、  
Main.xamlで、捕捉してくれましたねぇ。

Throwは、BusinessRuleExceptionなどを使うときだったか…

サンプルを張っておきました。ご笑覧ください。

---

<div class="post-metadata">

**Author:** ![kana612](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kana612/32/179008_2.png) [@kana612](https://forum.uipath.com/u/kana612)\
**Post date:** [January 9, 2020, 7:01am UTC](https://forum.uipath.com/t/topic/183465/8 "2020-01-09T07:01:09Z")

</div>

サンプルありがとうございます。  
キャッチしてくれました…  
本来であればできるということで、今回の件はクローズします。  
ありがとうございました。

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [January 12, 2020, 7:01am UTC](https://forum.uipath.com/t/topic/183465/9 "2020-01-12T07:01:09Z")

</div>

Closed on January 12, 2020, 7:01am UTC

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