Handles errors in controller functions by logging and sending a generic response.
The Express response object.
The error message to log and send.
Optional
The error object (optional, for logging).
The HTTP status code (default: 500).
Optional custom error code for the response.
handleError(res, "Failed to fetch user", err, 404, "USER_NOT_FOUND"); Copy
handleError(res, "Failed to fetch user", err, 404, "USER_NOT_FOUND");
Handles errors in controller functions by logging and sending a generic response.