mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-01-09 03:09:40 -06:00
23 lines
626 B
JavaScript
Executable File
23 lines
626 B
JavaScript
Executable File
import logger from "../utils/logger.js";
|
|
import ServiceRegistry from "../service/serviceRegistry.js";
|
|
import StringService from "../service/stringService.js";
|
|
|
|
const handleErrors = (error, req, res, next) => {
|
|
const status = error.status || 500;
|
|
const stringService = ServiceRegistry.get(StringService.SERVICE_NAME);
|
|
const message = error.message || stringService.friendlyError;
|
|
const service = error.service || stringService.unknownService;
|
|
logger.error({
|
|
message: message,
|
|
service: service,
|
|
method: error.method,
|
|
stack: error.stack,
|
|
});
|
|
res.error({
|
|
status,
|
|
msg: message,
|
|
});
|
|
};
|
|
|
|
export { handleErrors };
|