Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Error

The wrapper class for all errors that occur inside hackerapi.js. It provides a constant API for all types of errors that can occur with the API.

class

Hierarchy

  • Error

Index

Constructors

constructor

  • new Error(err: AxiosError): Error
  • Converts a generic Axios error into a specialized HackerAPI error

    Parameters

    • err: AxiosError

    Returns Error

Properties

message

message: string

type

type: number

Static listeners

listeners: GlobalListener[]

Accessors

Static BAD_REQUEST

  • get BAD_REQUEST(): number

Static FAILED_SETUP

  • get FAILED_SETUP(): number
  • Something happened in setting up the request that triggered an error

    static
    example

    .catch((err) => { if (err.type === Error.FAILED_SETUP) console.log(":("); })

    Returns number

Static NOT_FOUND

  • get NOT_FOUND(): number

Static NO_RESPONSE

  • get NO_RESPONSE(): number
  • The request was made but no response was received from the server.

    static
    example

    .catch((err) => { if (err.type === Error.NO_RESPONSE) console.log(":("); })

    Returns number

Static UNAUTHORIZED

  • get UNAUTHORIZED(): number
  • Either no token is provided or the token isn't authorized to make that request

    static

    Returns number

Static UNKNOWN_ERROR

  • get UNKNOWN_ERROR(): number

Methods

Static addGlobalListener

  • Adds a callback to be called whenever a global error is fired

    example

    let gl = new HackerAPI.Error.GlobalListener(() => alert("Oh no"), [HackerAPI.Error.UNKNOWN_ERROR]); HackerAPI.Error.addGlobalListener(foo);

    Parameters

    Returns void

Static fireListeners

  • fireListeners(error: Error): void
  • Fires a new error for global error listeners to handle

    Parameters

    Returns void

Static removeGlobalListener

Generated using TypeDoc