Merge pull request #744 from automatisch/extend-http-error

feat(http-error): add response
This commit is contained in:
Ömer Faruk Aydın
2022-11-25 20:01:25 +01:00
committed by GitHub

View File

@@ -1,12 +1,17 @@
import type { AxiosResponse, AxiosError } from 'axios';
import { IJSONObject } from '@automatisch/types'; import { IJSONObject } from '@automatisch/types';
import BaseError from './base'; import BaseError from './base';
export default class HttpError extends BaseError { export default class HttpError extends BaseError {
constructor(error: IJSONObject) { response: AxiosResponse;
constructor(error: AxiosError) {
const computedError = const computedError =
((error.response as IJSONObject)?.data as IJSONObject) || error.response?.data as IJSONObject ||
(error.message as string); error.message as string;
super(computedError); super(computedError);
this.response = error.response;
} }
} }