---
schema_version: "1"
id: 122d5a246d7abe4bc11d85a44362febba12f1f44d757944e8f6cd64f546e5fed
title: orElseTry
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.8/dw-runtime-functions-orelsetry.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.8/dw-runtime-functions-orelsetry
source_site: docs.mulesoft.com
content_type: documentation
content_hash: ec1c443f5c7da7616c5643fbe821b0a024219baa5cd500c006ee9598d102b023
description: MuleSoft Documentation Site
release: "2.8"
latest: false
---
# orElseTry

## [](#orelsetry1)orElseTry<T, R>(previous: TryResult<T>, orElse: () -> R): TryResult<T | R>

複数の ​`try`​ 要求を連結するために ​`try`​ で使用する関数。

_DataWeave バージョン 2.2.0 で導入されました。_

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

<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>previous</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>try</code>​ に対する前のコールの結果。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>orElseTry</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>previous</code>​ 引数が失敗する場合に試行する引数。</p></td>
</tr>
</tbody>
</table>

### [](#例)例

次の例は、異なる try をチェーニングする方法を示しています。

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

```DataWeave
%dw 2.0
import * from dw::Runtime
var user = {}
var otherUser = {}
output application/json
---
{
    a: try(() -> user.name!) orElseTry otherUser.name!,
    b: try(() -> user.name!) orElseTry "No User Name"
}
```

#### [](#出力)出力

```JSON
{
  "a": {
    "success": false,
    "error": {
      "kind": "KeyNotFoundException",
      "message": "There is no key named 'name'",
      "location": "\n9|     a: try(() -> user.name!) orElseTry otherUser.name!,\n                                          ^^^^^^^^^^^^^^",
      "stack": [
        "main (org::mule::weave::v2::engine::transform:9:40)"
      ]
    }
  },
  "b": {
    "success": true,
    "result": "No User Name"
  }
}
```