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

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

複数の ​`try`​ をチェーニングするために try で使用される関数

_DataWeave 2.2.0 で導入されました。Mule 4.2 以降でサポートされます。_​

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

<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">前の try 結果</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">​<code>orElse</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">前の try が失敗した場合に試行する次のオプション</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"
  }
}
```