---
schema_version: "1"
id: 7ebf36047a99e2b116ffca1a9c7f278238bf91fc0393da9c7587aa64cacfa40e
title: orElseTry
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.4/dw-runtime-functions-orelsetry.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.4/dw-runtime-functions-orelsetry
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 250f2565967cc8250fa3d550f70fc60fa35eb8a7c3043788cf16d022d5a3220c
description: MuleSoft Documentation Site
release: "2.4"
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"
  }
}
```