@prass/botpress-native
Version:
A simple and powerful SDK for integrating Botpress Chat API with React Native,
27 lines (24 loc) • 911 B
JavaScript
import { AxiosError } from 'axios';
/**
* Custom API Exception class extending AxiosError.
* This class extracts only necessary error details for cleaner error handling.
*/
class Exception extends AxiosError {
constructor(error) {
var _a, _b, _c;
delete ((_a = error.response) !== null && _a !== void 0 ? _a : {}).config;
delete ((_b = error.response) !== null && _b !== void 0 ? _b : {}).request;
super(error.message, error.code, error.response);
this.statusCode = (_c = error.response) === null || _c === void 0 ? void 0 : _c.status;
// clean prototype
Object.setPrototypeOf(this, new.target.prototype);
}
/**
* Returns a clean error message.
*/
toString() {
return `Exception: ${this.statusCode ? `(${this.statusCode}) ` : ""}${this.message}`;
}
}
export { Exception };
//# sourceMappingURL=exceptions.js.map