Options
All
  • Public
  • Public/Protected
  • All
Menu

Class SystemError

Extended system error class.

Hierarchy

  • Error
    • SystemError

Index

Constructors

Properties

Methods

Constructors

constructor

  • new SystemError(code: string, message: string): SystemError
  • Creates an instance of SystemError.

    throws

    Error Throwing error if the code already defined

    Parameters

    • code: string

      Error code

    • message: string

      Error message

    Returns SystemError

Properties

code

code: string

Error code.

message

message: string

name

name: string

Optional stack

stack: undefined | string

Static Error

Error: ErrorConstructor

Methods

Static isSystemError

  • Check if an object is indeed a functional SystemError.

    Note

    • Not checking for presence of code property, or for it being a string, as assuming that the object of SystemError type would have it initialized.
    • Empty code errors will return false, due to the ambiguity.

    Usage

    // Try to load JSON
    try{
      loadJson();
    } catch(error) {
      if (SystemError.isSystemError(error)){
        // If error is something that we have defined, throw a more generic error
        throw new SystemError("json_load_fail", "Failed to load JSON file.");
      } else {
        // Rethrow the original error
        throw error;
      }
    }

    Parameters

    Returns boolean

    Returns true if is is a SystemError, false if not.

Generated using TypeDoc