feat: Introduce http error class

This commit is contained in:
Faruk AYDIN
2022-10-28 13:36:28 +02:00
parent 2b6ff7de41
commit c3a54e0c69
3 changed files with 8 additions and 4 deletions

View File

@@ -2,6 +2,7 @@ import axios, { AxiosRequestConfig } from 'axios';
export { AxiosInstance as IHttpClient } from 'axios';
import { IHttpClientParams } from '@automatisch/types';
import { URL } from 'url';
import HttpError from '../../errors/http-error';
const removeBaseUrlForAbsoluteUrls = (
requestConfig: AxiosRequestConfig
@@ -39,8 +40,7 @@ export default function createHttpClient({
instance.interceptors.response.use(
(response) => response,
(error) => {
error.response.httpError = error.response.data;
throw error;
throw new HttpError(error.response.data);
}
);