mirror of
https://github.com/axios/axios.git
synced 2026-04-11 02:11:50 +08:00
* fix: turn AxiosError into a native error (#5394) Being an object returned by the 'Error' constructor turns something into a 'native error'. * fix: simplify code in AxiosError * fix: simplify code in AxiosError * refactor: implement AxiosError as a class * refactor: implement CanceledError as a class This turns CanceledError into a native error. * refactor: simplify AxiosError.toJSON * fix: improve error code handling in `AxiosError.from` If no error code is provided, use the code from the underlying error. * fix: set error status in `AxiosError.constructor` If a response is passed to the constructor, set the response status as a property. * fix: remove unnecessary async --------- Co-authored-by: Jay <jasonsaayman@gmail.com>
23 lines
618 B
JavaScript
23 lines
618 B
JavaScript
'use strict';
|
|
|
|
import AxiosError from '../core/AxiosError.js';
|
|
|
|
class CanceledError extends AxiosError {
|
|
/**
|
|
* A `CanceledError` is an object that is thrown when an operation is canceled.
|
|
*
|
|
* @param {string=} message The message.
|
|
* @param {Object=} config The config.
|
|
* @param {Object=} request The request.
|
|
*
|
|
* @returns {CanceledError} The created error.
|
|
*/
|
|
constructor(message, config, request) {
|
|
super(message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
|
|
this.name = 'CanceledError';
|
|
this.__CANCEL__ = true;
|
|
}
|
|
}
|
|
|
|
export default CanceledError;
|