Skip to content

fail

Returns an EitherLeft<"fail", never>: perfect to signal a failure without carrying extra data.

TIP

fail is the payload-less alias of left("fail"). For details on customizing the info or adding a value, read the left page.

Interactive example

Syntax

typescript
function fail(): EitherFail

Parameters

None: the call solely represents the fact that an operation did not succeed.

Return value

A Left tagged "fail" whose wrapped value is never. Combine it with E.whenHasInformation(result, "fail", handler) to run specific logic when no data is available.

Use cases

  • A command that fails but has no useful detail to pass along.
  • A safeguard ensuring a branch always returns a Left even without context.
  • Simplify tests by checking only the "fail" info.

See also

  • error – Variant with payload.
  • ok – Payload-less Right counterpart.
  • left – To build your own contextualized errors.

Released under the MIT license.