Skip to content

Commit

Permalink
Refactor notification controller error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
PooyaRaki committed Dec 5, 2024
1 parent ac5074b commit 6a9aa2f
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/routes/notifications/v1/notifications.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,9 @@ export class NotificationsController {
} catch (error: unknown) {
// The token might already have been removed from the TX service.
// If this happens, the TX service will throw a 404 error, but it is safe to ignore it.
if (error instanceof Error) {
if ('code' in error && error.code !== 404) {
throw error;
}
const errorObject = error as { code?: number };
if (errorObject?.code !== 404) {
throw error;
}
}
}
Expand Down Expand Up @@ -258,10 +257,9 @@ export class NotificationsController {
} catch (error: unknown) {
// The token might already have been removed from the TX service.
// If this happens, the TX service will throw a 404 error, but it is safe to ignore it.
if (error instanceof Error) {
if ('code' in error && error.code !== 404) {
throw error;
}
const errorObject = error as { code?: number };
if (errorObject?.code !== 404) {
throw error;
}
}
}
Expand Down

0 comments on commit 6a9aa2f

Please sign in to comment.