Skip to content

Commit

Permalink
uses error logging and error handling middleware to detect errors wit…
Browse files Browse the repository at this point in the history
…h retrieving status credential
  • Loading branch information
kezike committed Feb 9, 2024
1 parent 95227b7 commit f023a2a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,20 @@ export async function build(opts = {}) {
return null;
}
const statusCredentialId = req.params.statusCredentialId;
let errorMessage;
try {
const statusCredential = await status.getStatusCredential(statusCredentialId);
if (!statusCredential) {
errorMessage = `Unable to find Status Credential with ID "${statusCredentialId}".`;
return res.status(404).send(errorMessage);
next({
message: `Unable to find Status Credential with ID "${statusCredentialId}".`,
code: 404
});
}
return res.status(200).json(statusCredential);
} catch (error) {
return res.status(error.code).send(error.message);
next({
message: error.message,
code: error.code
});
}
});

Expand Down

0 comments on commit f023a2a

Please sign in to comment.