Skip to content

Commit

Permalink
Merge pull request #44 from atlp-rwanda/43-issue-linting-errors-causi…
Browse files Browse the repository at this point in the history
…ng-ci-actions-to-fail

Removed unnecesary type annotation and console logs in errorHandler
  • Loading branch information
Habinezajanvier authored May 2, 2024
2 parents 5a92978 + 0660a85 commit 33083b0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/middlewares/errorHandler.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Request, Response, NextFunction } from 'express';

type MiddlewareFunction = (req: Request, res: Response, next: NextFunction) => Promise<void>;

function errorHandler(func: Function) {
function errorHandler(func: MiddlewareFunction) {
return async (req: Request, res: Response, next: NextFunction) => {
try {
await func(req, res, next);
} catch (error: any) {
console.log({ error });
} catch (error) { // Removed the type annotation from the catch clause variable because it caused liting errors
const message = error.detail || 'Internal Server Error';
res.status(500).send(message);
}
Expand Down

0 comments on commit 33083b0

Please sign in to comment.