feat: added proper validations for errors with messages

Signed-off-by: Varun Raj <varun@skcript.com>
This commit is contained in:
Varun Raj committed 2025-01-19 10:31:44 +05:30
1 parent d5c6f0ac29
commit 9fcda54e4f
8 files changed
+95 -37

No files matched your search

+15 -2
View File
@@ -2,6 +2,21 @@ import type { AxiosError, AxiosRequestConfig, Method } from 'axios'
import axios from 'axios'
import qs from 'qs'
export class APIError extends Error {
status: number;
constructor({
message,
status,
}: {
message: string;
status: number;
}) {
super(message);
this.name = 'APIError';
this.message = message;
this.status = status;
}
}
const handleErrors = (error: AxiosError | any) => {
@@ -26,8 +41,6 @@ const handleErrors = (error: AxiosError | any) => {
}
export default class API {
static setBaseURL(url: string) {
if (url) {
axios.defaults.baseURL = url