Options
All
  • Public
  • Public/Protected
  • All
Menu

Try - v2.0.0

Index

Classes

Block Type aliases

Other Type aliases

Functions

Block Type aliases

CatchBlock

CatchBlock: (e: Error) => void

A function containing the code to be executed as part of a catch block.

Type declaration

    • Parameters

      • e: Error

        the caught (and matched) error to be handled

      Returns void

FinallyBlock

FinallyBlock: () => void

A function containing the code to be executed as part of a finally block.

Type declaration

    • (): void
    • Returns void

TryBlock

TryBlock: () => void

A function containing the code to be executed as part of a try block.

Type declaration

    • (): void
    • Returns void

Other Type aliases

CatchMap

CatchMap: {}

A mapping of Error types to their corresponding CatchBlock.

Type declaration

ThrowableType

ThrowableType: {}

Represents a constructor of Error or one of its subclasses. Primarily used when specifying which type of error will be caught.

Type declaration

Functions

Handle

  • Manages incoming errors from within a catch block. All unmatched errors will be re-thrown.

    try {
      // Do something...
    } catch (e) {
      Handle(e, {
        Exception: e => {
          // Handle a caught error of type Exception.
        },
        ReferenceError: e => {
          // Handle a caught error of type ReferenceError.
        }
      })
    }

    Parameters

    • e: Error

      the caught error to be handled

    • catches: CatchMap

      the CatchBlocks to be used for each type of expected error

    Returns void

Try

  • Initializes a new try/catch/finally sequence.

    Try(() => {
      // Do something...
    })
    .Catch(Exception, e => {
      // Handle a caught error of type Exception.
    })
    .Finally(() => {
      // Do something else...
    })
    .Done()

    Parameters

    • callback: TryBlock

      the function to be executed as the try block

    Returns Runner

Generated using TypeDoc