---
schema_version: "1"
id: 4c0c190244f5f0ca124d32c70372b9e362810582bf21f6a083ea5b34aa9d0521
title: Try スコープ XML リファレンス
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/mule-runtime/4.6/try-scope-xml-reference.md
canonical_url: https://docs.mulesoft.com/jp/mule-runtime/4.6/try-scope-xml-reference
source_site: docs.mulesoft.com
content_type: documentation
content_hash: b6ede2a56c6e73bd1811cb323b499b14e113ae34d4c146c393cc6d87e106c645
description: MuleSoft Documentation Site
release: "4.6"
latest: false
---
# Try スコープ XML リファレンス

Try スコープは、次の構造で定義します。

- 1 つのルート要素 ​`<try>`
- Try スコープが定義するエラー処理ルールに従って実行されるコンポーネントは、​`try`​ 要素の子要素として定義されます。1 つまたは複数のコンポーネントを定義できます。
- 1 つの ​`<error-handler>`​ 要素で、スコープのすべてのエラー処理戦略を定義します。
- エラーハンドラーでは、1 つまたは複数の ​`on-error-continue`​ と ​`on-error-propagate`​ によってさまざまな戦略を定義します。いずれか 1 つは必須です。
- 一致するエラーが発生した時点で実行されるコンポーネントは、​`on-error`​ 要素の子要素として定義されます。1 つまたは複数のコンポーネントを定義できます。

```xml
<try>
  <!-- COMPONENTS TO TRY TO USE -->
  <error-handler>
    <on-error-continue>
      <!-- COMPONENTS TO USE IN CASE OF ERROR -->
    </on-error-continue>
    <on-error-propagate>
      <!-- COMPONENTS TO USE IN CASE OF ERROR -->
    </on-error-propagate>
  </error-handler>
</try>
```

Try スコープ (​`on-error-*`​) の各エラー処理戦略は、条件に従って実行されます。この条件は、通常は現在のエラーと一致するエラー種別 (または複数種別のリスト) です。​`error.cause.message.contains("fatal")`​ のように、自由に作成した式として条件を定義することもできます。

<table><tbody><tr><td class="icon"><i class="fa icon-note" title="Note"></i></td><td class="content">条件は順番に評価され、最初に一致した戦略のみが実行されます。</td></tr></tbody></table>

2 つのエラー処理戦略を定義した例を示します。それぞれがロガーコンポーネントを実行します。

```xml
<try>
  <http:request config-ref="HTTP-config" method="GET" path="/" />
  <error-handler>
    <on-error-continue enableNotifications="true" logException="true" type="CONNECTIVITY">
      <logger level="INFO" doc:name="Logger" message="Connectivity Error"/>
    </on-error-continue>
    <on-error-propagate enableNotifications="true" logException="true" doc:name="On Error Propagate" type="EXPRESSION">
      <logger level="INFO" doc:name="Logger" message="Expression error" />
    </on-error-propagate>
  </error-handler>
</try>
```

## [](#try-のプロパティ)Try のプロパティ

<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 20%;">
<col style="width: 20%;">
<col style="width: 60%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">プロパティ</th>
<th class="tableblock halign-left valign-top">Default (デフォルト)</th>
<th class="tableblock halign-left valign-top">説明</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><code>transactionalAction</code></p>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">INDIFFERENT</p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>スコープ内のアクションをトランザクションとして扱うかどうかを定義します。可能な値:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>INDIFFERENT: スコープ内のアクションをトランザクションとして扱いません。</p>
</li>
<li>
<p>ALWAYS_BEGIN​: スコープを実行する度に、新しいトランザクションが開始されます。</p>
</li>
<li>
<p>BEGIN_OR_JOIN​: フローの現在の処理ですでにトランザクションが開始されている場合は、そのトランザクションに結合します。開始されていなければ、新しいトランザクションを開始します。(実行順序が変化する場合にのみ適用されます。)</p>
</li>
</ul>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><code>transactionalType</code></p>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">LOCAL</p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>使用するトランザクションの種別を定義します。可能な値:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>"LOCAL"</p>
</li>
<li>
<p>"XA"</p>
</li>
</ul>
</div></div></td>
</tr>
</tbody>
</table>

## [](#関連情報)関連情報

- [Try スコープの概念](https://docs.mulesoft.com/jp/mule-runtime/4.6/try-scope-concept)
- [エラー処理](https://docs.mulesoft.com/jp/mule-runtime/4.6/error-handling)