diff --git a/packages/backend/src/errors/http.ts b/packages/backend/src/errors/http.ts index d4396f50..d7a38e13 100644 --- a/packages/backend/src/errors/http.ts +++ b/packages/backend/src/errors/http.ts @@ -1,12 +1,17 @@ +import type { AxiosResponse, AxiosError } from 'axios'; import { IJSONObject } from '@automatisch/types'; import BaseError from './base'; export default class HttpError extends BaseError { - constructor(error: IJSONObject) { + response: AxiosResponse; + + constructor(error: AxiosError) { const computedError = - ((error.response as IJSONObject)?.data as IJSONObject) || - (error.message as string); + error.response?.data as IJSONObject || + error.message as string; super(computedError); + + this.response = error.response; } }