ApiError.ts 495 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22


class ApiError {
    public status: number;
    public statusText: string;
    public data: any;

    public static axiosError(err): ApiError {
        const ae = new ApiError();
        if (err.response) {
            ae.status = err.response.status;
            ae.statusText = err.response.statusText;
            ae.data = err.response.data;
        } else {
            ae.status = -1;
            ae.data = 'Unknown error';
        }
        return ae;
    }
}

export default ApiError;