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

## [](#causedby1)causedBy(@DesignOnlyType error: Error, errorType: 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 が使用する変数です ( [Mule Runtime の DataWeave 変数](https://docs.mulesoft.com/dataweave/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>
```