Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
dohaki committed Sep 23, 2024
1 parent a6a5073 commit b4ce24f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions api/_errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,23 +213,25 @@ export function handleErrorCondition(
else if (typeguards.isEthersError(error)) {
acrossApiError = resolveEthersError(error);
}
// Rethrow instances of `AcrossApiError`
else if (error instanceof AcrossApiError) {
acrossApiError = error;
}
// Handle other errors
else if (error instanceof Error) {
else {
acrossApiError = new AcrossApiError(
{
message: error.message,
message: (error as Error).message,
status: HttpErrorToStatusCode.INTERNAL_SERVER_ERROR,
},
{ cause: error }
);
} else {
acrossApiError = error as AcrossApiError;
}

const logLevel = acrossApiError.status >= 500 ? "error" : "warn";
logger[logLevel]({
at: endpoint,
message: `${acrossApiError.code}: ${acrossApiError.message}`,
message: `Status ${acrossApiError.status} - ${acrossApiError.message}`,
});

return response.status(acrossApiError.status).json(acrossApiError);
Expand Down

0 comments on commit b4ce24f

Please sign in to comment.