Skip to content

Commit

Permalink
Return a proper 400 error when a trace is not found in the trace store (
Browse files Browse the repository at this point in the history
#859)

Return a proper 404 error when a trace is not found in the trace store

Co-authored-by: Pavel Jbanov <[email protected]>
  • Loading branch information
MichaelDoyle and pavelgj authored Sep 5, 2024
1 parent 3aa7cb5 commit f978fd3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion js/core/src/reflectionApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,13 @@ export async function startReflectionApi(port?: number | undefined) {
// TODO: Remove try/catch when upgrading to Express 5; error is sent to `next` automatically
// in that version
try {
response.json(await tracestore?.load(traceId));
const trace = await tracestore?.load(traceId);
return trace
? response.json(trace)
: response.status(404).send({
code: StatusCodes.NOT_FOUND,
message: `Trace with traceId=${traceId} not found.`,
});
} catch (err) {
const error = err as Error;
const { message, stack } = error;
Expand Down

0 comments on commit f978fd3

Please sign in to comment.