mirror of
https://github.com/kirameki-cafe/Yumi.git
synced 2026-09-13 10:49:20 +00:00
Added API
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import HTTP_STATUS from "../libs/HTTPStatus";
|
||||
import Logger from "../libs/Logger";
|
||||
import { ServiceError } from "./Errors";
|
||||
|
||||
class ExpressExceptionHandler {
|
||||
public static errorLogger(error: any, req: any, res: any, next: any) {
|
||||
if(error instanceof ServiceError) {
|
||||
res.status(error.statusCode).json({
|
||||
error: error.message
|
||||
})
|
||||
}
|
||||
else {
|
||||
res.status(HTTP_STATUS.INTERNAL_SERVER_ERROR).json({
|
||||
error: "Internal server error"
|
||||
})
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default ExpressExceptionHandler;
|
||||
Reference in New Issue
Block a user