MoyalError

MoyalError

Custom error class with nested error support. Automatically uses native `cause` if supported, otherwise simulates it.

Constructor

new MoyalError(message, secondopt)

Description:
  • Constructs a new MoyalError instance.
Source:
Parameters:
Name Type Attributes Default Description
message string No message description was set to this error. The error message.
second object | Error | string | null <optional>
null Either an object with `{ cause }`, or a direct cause/error.

Classes

MoyalError

Members

cause

Description:
  • Gets the cause of the error (native or simulated).
Source:
Gets the cause of the error (native or simulated).

fullStack

Description:
  • Builds a full stack trace including all nested causes, recursively.
Source:
Builds a full stack trace including all nested causes, recursively.

(static) version

Description:
  • Returns the version of this library.
Source:
Returns the version of this library.

Methods

toJSON() → {MoyalErrorJSON}

Description:
  • Serializes the error into a JSON-friendly object, including metadata for structured logging.
Source:
Returns:
A plain object with name, message, stack, timestamp, and cause.
Type
MoyalErrorJSON

toString() → {string}

Description:
  • Returns a string representation of the error including chained causes.
Source:
Returns:
Type
string