JSPM

  • Created
  • Published
  • Downloads 14292
  • Score
    100M100P100Q153206F
  • License MIT

Axios error wrapper that aim to provide clear error message to developers

Package Exports

  • axios-error

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (axios-error) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

axios-error

Axios error wrapper that aim to provide clear error message to developers

Installation

npm i --save axios-error

or

yarn add axios-error

Usage

const AxiosError = require('axios-error');

// You can construct it from the error thrown by axios
const error = new AxiosError(errorThrownByAxios);

// Or with an custom error message
const error = new AxiosError(message, errorThrownByAxios);

// Or construct it from axios config, axios request and axios response
const error = new AxiosError(message, { config, request, response });

Calling console.log on the error instance returns the formatted message. If you'd like to get the axios request, response, or config, you can still get them via the following keys on the error instance:

console.log(error); // formatted error message
console.log(error.stack); // error stack trace
console.log(error.config); // axios request config
console.log(error.request); // HTTP request
console.log(error.response); // HTTP response