Skip to content

Commit 8a379c1

Browse files
committed
Don't use a namespace for ApiError.Message
1 parent 59dabcf commit 8a379c1

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

src/templates/core/ApiError.ts

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,15 @@ export class ApiError extends Error {
2222
}
2323
}
2424

25-
export namespace ApiError {
26-
export enum Message {
27-
BAD_REQUEST = 'Bad Request',
28-
UNAUTHORIZED = 'Unauthorized',
29-
FORBIDDEN = 'Forbidden',
30-
NOT_FOUND = 'Not Found',
31-
INTERNAL_SERVER_ERROR = 'Internal Server Error',
32-
BAD_GATEWAY = 'Bad Gateway',
33-
SERVICE_UNAVAILABLE = 'Service Unavailable',
34-
GENERIC_ERROR = 'Generic Error',
35-
}
25+
export enum ApiErrorMessage {
26+
BAD_REQUEST = 'Bad Request',
27+
UNAUTHORIZED = 'Unauthorized',
28+
FORBIDDEN = 'Forbidden',
29+
NOT_FOUND = 'Not Found',
30+
INTERNAL_SERVER_ERROR = 'Internal Server Error',
31+
BAD_GATEWAY = 'Bad Gateway',
32+
SERVICE_UNAVAILABLE = 'Service Unavailable',
33+
GENERIC_ERROR = 'Generic Error',
3634
}
3735

3836
/**
@@ -41,16 +39,16 @@ export namespace ApiError {
4139
*/
4240
export function catchGenericError(result: Result): void {
4341
switch (result.status) {
44-
case 400: throw new ApiError(result, ApiError.Message.BAD_REQUEST);
45-
case 401: throw new ApiError(result, ApiError.Message.UNAUTHORIZED);
46-
case 403: throw new ApiError(result, ApiError.Message.FORBIDDEN);
47-
case 404: throw new ApiError(result, ApiError.Message.NOT_FOUND);
48-
case 500: throw new ApiError(result, ApiError.Message.INTERNAL_SERVER_ERROR);
49-
case 502: throw new ApiError(result, ApiError.Message.BAD_GATEWAY);
50-
case 503: throw new ApiError(result, ApiError.Message.SERVICE_UNAVAILABLE);
42+
case 400: throw new ApiError(result, ApiErrorMessage.BAD_REQUEST);
43+
case 401: throw new ApiError(result, ApiErrorMessage.UNAUTHORIZED);
44+
case 403: throw new ApiError(result, ApiErrorMessage.FORBIDDEN);
45+
case 404: throw new ApiError(result, ApiErrorMessage.NOT_FOUND);
46+
case 500: throw new ApiError(result, ApiErrorMessage.INTERNAL_SERVER_ERROR);
47+
case 502: throw new ApiError(result, ApiErrorMessage.BAD_GATEWAY);
48+
case 503: throw new ApiError(result, ApiErrorMessage.SERVICE_UNAVAILABLE);
5149
}
5250

5351
if (!isSuccess(result.status)) {
54-
throw new ApiError(result, ApiError.Message.GENERIC_ERROR);
52+
throw new ApiError(result, ApiErrorMessage.GENERIC_ERROR);
5553
}
5654
}

0 commit comments

Comments
 (0)