forked from Fortnite-API/nodejs-wrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFortniteAPIError.ts
More file actions
45 lines (38 loc) · 1012 Bytes
/
Copy pathFortniteAPIError.ts
File metadata and controls
45 lines (38 loc) · 1012 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { AxiosRequestConfig } from 'axios';
import { FortniteAPIErrorData } from '../http/httpStructs';
/**
* Represets a Fortnite-API HTTP error
*/
class FortniteAPIError extends Error {
/**
* The HTTP method
*/
public method: string;
/**
* The URL of the requested API endpoint
*/
public url: string;
/**
* The HTTP status code
*/
public httpStatus: number;
/**
* The request url query params sent by the client
*/
public requestParams?: any;
/**
* @param error The raw Fortnite-API error data
* @param request The client's request
* @param status The response's HTTP status
*/
constructor(error: FortniteAPIErrorData, request: AxiosRequestConfig, status: number) {
super();
this.name = 'FortniteAPIError';
this.message = error.error;
this.method = request.method?.toUpperCase() ?? 'GET'
this.url = request.url!;
this.httpStatus = status;
this.requestParams = request.params;
}
}
export default FortniteAPIError;