mwbot-ts - v1.2.7
    Preparing search index...

    Class MwbotError<K>

    Custom error class for Mwbot, extending the built-in Error class. This class is exported for use with the instanceof operator.

    This error class is used throughout Mwbot to standardize error handling, ensuring that all errors and rejected Promises include a stack trace for easier debugging.

    For a list of error codes, see MwbotErrorCodes.

    Type Parameters

    Hierarchy

    • Error
      • MwbotError
    Index

    Constructors

    Properties

    cause?: unknown
    code: string

    The code of the error.

    Additional data of the error.

    info: string

    The information of the error.

    name: string
    stack?: string
    type: K

    The type of the error.

    prepareStackTrace?: (err: Error, stackTraces: CallSite[]) => any

    Optional override for formatting stack traces

    stackTraceLimit: number

    Accessors

    • get message(): string

      Returns the info property. This property is only for compatibility with the parent Error class.

      Returns string

    Methods

    • Updates the error information.

      Parameters

      • info: string

        The new error information.

      Returns this

      The current instance for chaining.

    • Create .stack property on a target object

      Parameters

      • targetObject: object
      • OptionalconstructorOpt: Function

      Returns void

    • Creates a new instance from an API error response.

      Parameters

      • response: Required<Pick<ApiResponse, "error">> | Required<Pick<ApiResponse, "errors">>

        An API response with the error or errors property.

      Returns MwbotError<"api">

      A new MwbotError instance.