すべてのプロダクト
Search
ドキュメントセンター

CloudFlow:fail ステップ

最終更新日:Aug 27, 2026

このトピックでは、fail ステップについて説明し、その使用法の例を示します。

概要

fail ステップは、ステップのシーケンスを早期に終了させます。これは、プログラミング言語における raisethrow のような操作に似ています。フローが fail ステップを実行すると、後続のステップは実行されません。fail ステップは、その親ステップを失敗させます。この失敗は上方に伝播し、最終的にフロー全体が失敗します。

fail ステップには、次のプロパティがあります。

  • (必須) type:ステップのタイプ。値は fail にする必要があります。
  • (必須) name:ステップの名前。
  • (オプション) error:フォルトのタイプ。
  • (オプション) cause:フォルトの理由。
  • (オプション) inputMappings:入力マッピング。
  • (オプション) outputMappings:出力マッピング。

次のフロー定義では、fail ステップを使用してフロー実行を早期に終了します。

  • 入力の statusready の場合、フローは最初の choice ブランチの pass1 ステップを実行し、その後 final ステップを実行します。
  • 入力の statusfailed の場合、フローは 2 番目の choice ブランチの goto 指示に従い、handle_failure ステップを実行します。handle_failure は fail ステップであるため、フローは handle_failure の後に final ステップを実行しません。
  • 入力に status が含まれていない場合、または statusready でも failed でもない場合、フローは、デフォルトブランチの pass2 ステップを実行し、次に handle_failure ステップを実行します。
version: v1
type: flow
steps:
  - type: choice
    name: mychoice
    choices:
      - condition: $.status == "ready"
        # ステップを持つ choice
        steps:
          - type: pass
            name: pass1
        goto: final
      - condition: $.status == "failed"
        goto: handle_failure
    default:
      # goto を使用する必要はありません
      steps:
        - type: pass
          name: pass2
  - type: fail
    name: handle_failure
    error: StatusIsNotReady
    cause: status is not ready
  - type: pass
    name: final