FaasJS
Home
  • Guide
  • Documents
  • Templates
  • Changelog
  • Ecosystem

    • Docker Images
  • Github
  • Contributing
  • Sponsor
  • Security
Home
  • Guide
  • Documents
  • Templates
  • Changelog
  • Ecosystem

    • Docker Images
  • Github
  • Contributing
  • Sponsor
  • Security

Documents / @faasjs/workflow / fail

Function: fail()

fail(error, options?): FailWorkflowInstruction

Mark the current step as failed. When options.next is provided, the workflow continues with that next step after recording the failure.

Parameters

error

unknown

Failure reason to persist.

options?

Optional recoverable-failure continuation.

next?

WorkflowStepTarget

Returns

FailWorkflowInstruction

Example

import { done, fail } from '@faasjs/workflow'

async function capturePayment({ params }) {
  try {
    await capturePaymentForOrder(params.orderId)

    return done()
  } catch (error) {
    return fail(error, {
      next: {
        name: 'releaseInventory',
        params: {
          orderId: params.orderId,
        },
      },
    })
  }
}