---
schema_version: "1"
id: ad9960fa08fe0205bb4f9df0a5122a4fddb56e582bc38a20444f10c947147b29
title: Raise Error (<raise-error/>)
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/anypoint-code-builder/acb-component-raise-error.md
canonical_url: https://docs.mulesoft.com/jp/anypoint-code-builder/acb-component-raise-error
source_site: docs.mulesoft.com
content_type: documentation
content_hash: bdde937929e07e2083431f4f06cc42302ca1b7335a66e5650940aa61a98af6e3
description: MuleSoft Documentation Site
latest: true
---
# Raise Error (<raise-error/>)

![logo cloud IDE](/mulesoft/current/ja-jp/_/img/logos/deployment-cloud-ide.png "Cloud IDE") Cloud IDE

![logo desktop IDE](/mulesoft/current/ja-jp/_/img/logos/deployment-desktop-ide.png "Desktop IDE") Desktop IDE

エラーが発生したことを示す Mule エラーを生成します。

エラーの説明と種別をカスタマイズできます。このコンポーネントは、次のエラーを生成するために使用します。

- `MULE:SECURITY`​、​`MULE:CONNECTIVITY`​ などのコアランタイムエラー。
- カスタムエラー種別。

別のコネクタや ​`FILE:FILE_NOT_FOUND`​ や ​`JSON:INVALID_SCHEMA`​ などのモジュールからエラーを発生させることはできません。コネクタの既存の名前空間を使用することはできません。

## [](#component-xml)コンポーネント XML

このコンポーネントは、次の XML 構造をサポートします。

```xml
<raise-error
  type="MULE:CONNECTIVITY"
  description="Error description message" />
```

Raise Error (​`<raise-error/>`​) 属性は UI および XML で設定できます。

<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">属性 XML</th>
<th class="tableblock halign-left valign-top">説明</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Raise error (エラー生成)</strong>​ (デフォルト)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>doc:name</code></p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>キャンバスに表示されるコンポーネントの編集可能な名前。</p>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">なし</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>doc:id</code></p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>コンポーネントの自動生成された識別子。</p>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Type (種別)</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>type</code></p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>エラーの種別。</p>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Description (説明)</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>description</code></p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>エラーの説明。</p>
</div></div></td>
</tr>
</tbody>
</table>

## [](#例)例

### [](#example1)例: 無効なユーザー入力後のエラーの発生

次の運転教習プラットフォームの例では、ユーザーが 16 歳以上であることを確認します。ユーザーが 16 歳未満の年齢を入力すると、フローでカスタム ​`PRECONDITIONS:INCORRECT_AGE`​ エラーが生成されます。

```xml
<http:listener-config name="HTTP_Listener_config">
  <http:listener-connection host="0.0.0.0" port="8081" />
</http:listener-config>
<flow name="raise-error-example-flow">
  <http:listener config-ref="HTTP_Listener_config" path="/test"/>
  <choice> (1)
    <when expression="#[message.attributes.queryParams.age &lt; 16]"> (2)
      <raise-error type="PRECONDITIONS:INCORRECT_AGE" description="Minimum age of 16 required to drive" />
    </when>
    <otherwise > (3)
      <logger level="INFO" message="User age above 16 years. Allowed to drive"/>
    </otherwise>
  </choice>
  <error-handler >
    <on-error-continue enableNotifications="true" logException="true" type="PRECONDITIONS:INCORRECT_AGE"> (4)
      <logger level="INFO" message="Minimum age to drive is 16 years old"/>
    </on-error-continue>
    <on-error-continue enableNotifications="true" logException="true"  type="MULE:EXPRESSION"> (5)
      <logger level="INFO" message="The parameter age is missing or invalid"/>
    </on-error-continue>
  </error-handler>
</flow>
```

<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Choice Router コンポーネントにより、条件処理がフローに追加されます。</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>要求で送信された age パラメーターが 16 (​<code>http://localhost:8081/test?age=15</code>​) 未満の場合、Raise Error コンポーネントでエラー種別 ​<code>PRECONDITIONS:INCORRECT_AGE</code>​ と説明 ​<code>Minimum age of 16 required to drive</code>​ が生成されます。</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>要求 (​<code>http://localhost:8081/test?age=17</code>​) の age パラメーターが 16 より大きい場合、Logger コンポーネントでデフォルトのメッセージ「。​<code>User age above 16 years.</code>​」が返されます​` Allowed to drive`​ が返されます。</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>On-Error Continue コンポーネントでエラー ​<code>PRECONDITIONS:INCORRECT_AGE</code>​ の種別が照合され、そのスコープ内で Logger コンポーネントが実行されます。Logger コンポーネントによってエラーメッセージ ​<code>Minimum age of 16 required to drive</code>​ が記録されます。</td>
</tr>
<tr>
<td><i class="conum" data-value="5"></i><b>5</b></td>
<td>要求 (​<code>http://localhost:8081/test</code>​) で age パラメーターが渡されない場合、式 ​<code>#[message.attributes.queryParams.age &lt; 16]</code>​ を評価しようとしたときに Choice コンポーネントで自動的に ​<code>MULE:EXPRESSION</code>​ エラーが生成されます。要求で age パラメーターが指定されなかったため、その値は null です。
<div class="paragraph">
<p>次に、On-Error Continue コンポーネントでエラー ​<code>MULE:EXPRESSION</code>​ の種別が照合され、そのスコープ内で Logger コンポーネントが実行されます。Logger コンポーネントによってメッセージ ​<code>The parameter age is missing or invalid</code>​ が返されます。</p>
</div></td>
</tr>
</tbody></table>

### [](#example2)例: 値を比較した後のエラーの発生

次の例では、API (https://unsecurebank.com/balance) に対する要求を行って返された口座残高を ​_balance_​ 変数に保存し、​`payload.amount`​ と比較して操作が可能かどうかを判断します。振込金額が利用可能残高を超えると Choice Router で ​`ACCOUNT:INSUFFICIENT_FUNDS`​ エラーが生成され、振込が行われないようにします。説明では、エラーの詳細が動的に提供されます。

```xml
<flow name="raise-error-example-flow">
  <http:request url="https://unsecurebank.com/balance" target="balance"/>
  <choice>
    <when expression="#[payload.amount > vars.balance]">
      <raise-error type="ACCOUNT:INSUFFICIENT_FUNDS" description="#['Cannot transfer $(payload.amount) since only $(vars.balance) are available.']"/>
    </when>
  </choice>
  <http:request url="https://unsecurebank.com/transfer"/>
</flow>
```

## [](#see-also)関連情報

- [Mule Errors](https://docs.mulesoft.com/mule-runtime/latest/mule-error-concept)
- [Error Handler (<error-handler/>)](https://docs.mulesoft.com/jp/anypoint-code-builder/acb-component-error-handler)