AI-Tennis-Coach/server/helper/catchAsyncAction/index.js
2025-02-11 11:23:59 +05:30

9 lines
275 B
JavaScript
Executable file

import { makeResponse, statusCodes } from "../index.js";
// Wrapper for catch block
export const catchAsyncAction = fn => {
return (req, res, next) => {
fn(req, res, next).catch((err) => makeResponse(res, statusCodes.BAD_REQUEST, false, err.message));
};
};