-
Notifications
You must be signed in to change notification settings - Fork 17
/
errors.ts
36 lines (35 loc) · 959 Bytes
/
errors.ts
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
export enum ErrorCode {
BadRequest = 400,
Unauthorized = 401,
Forbidden = 403,
NotFound = 404,
RequestTimeout = 408,
PreconditionFailed = 412,
InternalServerError = 500,
NotImplemented = 501,
BadGateway = 502,
ServiceUnavailable = 503,
}
export function getErrorMessage(errorCode: ErrorCode): string {
switch (errorCode) {
case ErrorCode.BadRequest:
return "bad request";
case ErrorCode.Unauthorized:
return "unauthorized";
case ErrorCode.Forbidden:
return "forbidden";
case ErrorCode.NotFound:
return "not found";
case ErrorCode.RequestTimeout:
return "request timeout";
case ErrorCode.PreconditionFailed:
return "precondition failed";
case ErrorCode.InternalServerError:
return "internal server error";
case ErrorCode.NotImplemented:
return "not implemented";
case ErrorCode.ServiceUnavailable:
return "service unavailable";
}
return "";
}