---
schema_version: "1"
id: aa0b4b7207ed6c6c7acd08b5d064d552c92d8781259c559fb999092a7af7883d
title: causedBy
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.3/dw-mule-functions-causedby.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.3/dw-mule-functions-causedby
source_site: docs.mulesoft.com
content_type: documentation
content_hash: f6aa1d37a0b49d0717f246d86bc20617c5951a51e31d7e0443d33292ecb5b45a
description: MuleSoft Documentation Site
release: "2.3"
latest: false
---
# causedBy

## [](#causedby1)causedBy(Error, String): Boolean

この関数は、エラーハンドラーのように、エラーをその種別によって一致させます。

`causedBy`​ は、上位の種別による一致だけでなく特定のサブ種別のロジックも必要な場合に役立ちます。また、異なる種別の子エラーを含む ​COMPOSITE\_ROUTING​ エラーを処理する場合にも役立つ可能性があります。

### [](#パラメーター)パラメーター

<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 75%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">名前</th>
<th class="tableblock halign-left valign-top">説明</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">​<code>error</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">省略可能。​<code>Error</code>​ (エラー) 型。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">​<code>errorType</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">HTTP:UNAUTHORIZED などのエラーを識別する文字列。</p></td>
</tr>
</tbody>
</table>

### [](#例)例

次の XML の例では、Mule エラー処理コンポーネントの ​`when`​ 式から ​`causedBy`​ をコールし、HTTP:UNAUTHORIZED エラーまたは HTTP:FORBIDDEN エラーのどちらが原因であるかに応じて SECURITY エラーを異なる方法で処理します。最初の式は ​`error`​ (​`Error`​ 型) を明示的に渡していますが、2 番目の式はパラメーターの値を指定せずに暗黙的に渡しています。 `error`​ は、Mule メッセージオブジェクトに関連付けられたエラーに対して DataWeave が使用する変数です。詳細は、 [「DataWeave Variables for Mule Runtime (Mule Runtime の DataWeave 変数)」](https://docs.mulesoft.com/mule-runtime/latest/dataweave-variables-context)​を参照してください。

#### [](#ソース)ソース

```XML
<error-handler name="securityHandler">
  <on-error-continue type="SECURITY">
    <!-- general error handling for all SECURITY errors -->
    <choice>
      <when expression="#[Mule::causedBy(error, 'HTTP:UNAUTHORIZED')]">
        <!-- specific error handling only for HTTP:UNAUTHORIZED errors -->
      </when>
      <when expression="#[Mule::causedBy('HTTP:FORBIDDEN')]">
        <!-- specific error handling only for HTTP:FORBIDDEN errors -->
      </when>
    </choice>
  </on-error-continue>
</error-handler>
```