Skip to content
Snippets Groups Projects
Commit 3ed4a5b5 authored by Anders Lindh Olsson's avatar Anders Lindh Olsson :8ball:
Browse files

Set body and status code if error from requestHandler

parent aaac9030
No related branches found
No related tags found
2 merge requests!542Prepare 4.1.0,!525CE-3072: Updated failing liveIocStatus test
Pipeline #195928 passed
......@@ -2,12 +2,20 @@ import { apiHandlers } from "../../src/mocks/mockAPI";
const glue = (requestHandler) => {
return (req) => {
const d = requestHandler(req);
req.reply({
body: d.body,
statusCode: d.status ?? 200,
headers: d.headers
});
try {
const res = requestHandler(req);
req.reply({
body: res.body,
statusCode: res.status ?? 200,
headers: res.headers
});
} catch (err) {
console.error("Error in requestHandler:", err);
req.reply({
body: { error: "Internal server error" },
statusCode: 500
});
}
};
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment