Skip to content

Commit 503b65d

Browse files
committed
feat: ensure ExpressRouteAdapter returns the error message instanced of the error name
1 parent 1ee6e53 commit 503b65d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/main/adapters/express-route-adapter.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ export const adaptRoute = (controller: Controller) => {
77
body: req.body,
88
};
99
const httpResponse = await controller.handle(httpRequest);
10-
res.status(httpResponse.statusCode).json(httpResponse.body);
10+
if (httpResponse.statusCode === 200) {
11+
res.status(httpResponse.statusCode).json(httpResponse.body);
12+
} else {
13+
res.status(httpResponse.statusCode).json({
14+
error: httpResponse.body.message,
15+
});
16+
}
1117
};
1218
};

0 commit comments

Comments
 (0)