-
Notifications
You must be signed in to change notification settings - Fork 0
🧹 [code health improvement] Use centralized error handling in autoNotifications #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,6 +8,7 @@ import { | |||||||||||||
| dismissShiftOngoingNotification, | ||||||||||||||
| syncShiftOngoingExpiry, | ||||||||||||||
| } from './shiftOngoingNotification'; | ||||||||||||||
| import { handleError } from './errorHandler'; | ||||||||||||||
|
|
||||||||||||||
| const NOTIF_IDS_KEY = 'aerostaff_notif_ids_v1'; | ||||||||||||||
| const LAST_SCHEDULE_KEY = 'aerostaff_notif_last_schedule'; | ||||||||||||||
|
|
@@ -133,8 +134,8 @@ export async function autoScheduleNotifications(): Promise<number> { | |||||||||||||
| trigger: { type: Notifications.SchedulableTriggerInputTypes.TIME_INTERVAL, seconds: Math.round(secondsUntilNotify), repeats: false }, | ||||||||||||||
| }); | ||||||||||||||
| newIds.push(id); | ||||||||||||||
| } catch (err) { | ||||||||||||||
| if (__DEV__) console.error('Failed to schedule arrival notification:', err); | ||||||||||||||
| } catch (err: unknown) { | ||||||||||||||
| handleError(err, 'notification', true); | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
|
|
@@ -186,8 +187,8 @@ export async function autoScheduleNotifications(): Promise<number> { | |||||||||||||
| }); | ||||||||||||||
| newIds.push(id); | ||||||||||||||
| } | ||||||||||||||
| } catch (err) { | ||||||||||||||
| if (__DEV__) console.error('Failed to schedule departure notification:', err); | ||||||||||||||
| } catch (err: unknown) { | ||||||||||||||
| handleError(err, 'notification', true); | ||||||||||||||
|
||||||||||||||
| handleError(err, 'notification', true); | |
| const contextualError = | |
| err instanceof Error | |
| ? new Error(`Failed to schedule departure notification for ${flightNumber}`, { cause: err }) | |
| : new Error(`Failed to schedule departure notification for ${flightNumber}: ${String(err)}`); | |
| handleError(contextualError, 'notification', true); |
Copilot
AI
Apr 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR description states "no behavior changes", but this catch block used to log only under __DEV__ and now always calls handleError, which currently always console.errors. If production logging is intended, consider updating the PR description; if not intended, gate the call (or add an option to handleError) to preserve the previous dev-only logging behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switching from a message-specific
console.error('Failed to schedule arrival notification:', err)tohandleError(err, 'notification', true)drops the location-specific log message and (with the currenthandleErrorimplementation) only logserror.message/String(error), which can lose stack traces and useful metadata. Consider passing additional context (e.g., wrap with a new Error including the original error as cause, or extendhandleErrorto accept an optional message/details and log the original error object).