Skip to content

Comments

feat #655: implements an error handling system with custom errors#657

Merged
shashilo merged 23 commits intodevelopfrom
hector/655-update-nextjs-error-responses
Nov 13, 2025
Merged

feat #655: implements an error handling system with custom errors#657
shashilo merged 23 commits intodevelopfrom
hector/655-update-nextjs-error-responses

Conversation

@suzuhe481
Copy link
Contributor

@suzuhe481 suzuhe481 commented Oct 27, 2025

Description

Before:

Backend routes/functions were thrown or returned without always being caught.

After:

  • Adds custom error classes to define specific error types with the file located in lib/errors/CustomErrors.ts.
    • BackendError, OpenAiError, SupabaseError, GoogleError
  • Errors will only be logged at the top level of where a function/route was called. Will typically be right before a response is sent to the client. Normally, this is the catch block inside of a route.ts.
  • Errors created/caught in nested functions will be continuously thrown until it gets caught in a catch block.
    • eg. The generateAndStoreSuggestions() function throws an OpenAiError, which gets rethrown in drawGiftExchange(), rethrown again in processGiftExchanges(), then finally caught and logged in a route.ts.
  • Some functions didn't need to return anything, but still returned a success: boolean. I removed these returns, but errors will still be thrown.
  • Added a logError(error: unknown) function located in lib/errors/logError.ts. This function is accepts the error to correctly identify and log it, as well as being easily expandable to new error types if they get created.

Closes #655

Screenshots

Example of error log in the terminal

Error log example

Pre-submission checklist

  • Code builds and passes locally
  • PR title follows Conventional Commit format (e.g. test #001: created unit test for __ component)
  • Request reviews from the Peer Code Reviewers and Senior+ Code Reviewers groups
  • Thread has been created in Discord and PR is linked in gis-code-questions

@vercel
Copy link

vercel bot commented Oct 27, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
elecretanta Ready Ready Preview Comment Nov 13, 2025 10:52pm
elecretanta-storybook Ready Ready Preview Comment Nov 13, 2025 10:52pm
elecretanta-unit-test Ready Ready Preview Comment Nov 13, 2025 10:52pm

@shashilo shashilo requested review from a team and shashilo and removed request for a team, HoldUpFjord, alexappleget, bethanyann, jennifertieu, kepsteen, nickytonline and shashilo October 27, 2025 22:41
@shashilo shashilo merged commit 7d0f0b3 into develop Nov 13, 2025
3 of 4 checks passed
@shashilo shashilo deleted the hector/655-update-nextjs-error-responses branch November 13, 2025 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update Next.js Responses to Display Full Error Message

2 participants