Skip to content
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

Add formatError property to Blitz server- & rpchandler setup #4124

Merged
merged 13 commits into from
May 1, 2023
Merged

Add formatError property to Blitz server- & rpchandler setup #4124

merged 13 commits into from
May 1, 2023

Conversation

dbrxnds
Copy link
Contributor

@dbrxnds dbrxnds commented Apr 9, 2023

Closes: https://discord.com/channels/802917734999523368/1094607326108983400

What are the changes and their implications?

Add a formatError callback property to setupBlitzServer and rpcHandler. Allowing users to add custom logic before an error gets returned to the client.

Example: Showing less descriptive errors in production such as "Internal server error occured" rather than a complete Prisma error.

Questions

  1. Would it be possible to pass the Blitz session public data to this callback function? This could allow for some logic based on roles / userid. I tried to make this work but I wasn't too sure about how to go about it, so I left it out for now.
  2. Would it be okay to extract the statusCode from the formattedError (if there is one) and use that for the response?

Bug Checklist

  • Changeset added (run pnpm changeset in the root directory)
  • Integration test added (see test docs if needed)

Feature Checklist

@changeset-bot
Copy link

changeset-bot bot commented Apr 9, 2023

🦋 Changeset detected

Latest commit: 3a25a84

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
@blitzjs/next Minor
@blitzjs/rpc Minor
next-blitz-auth Patch
@blitzjs/auth Minor
@blitzjs/codemod Minor
@blitzjs/config Minor
@blitzjs/generator Minor
blitz Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dbrxnds dbrxnds changed the title [] Add formatError property to Blitz server- & rpchandler setup Add formatError property to Blitz server- & rpchandler setup Apr 9, 2023
@siddhsuresh siddhsuresh self-requested a review April 10, 2023 01:10
@siddhsuresh siddhsuresh merged commit eda14fa into blitz-js:main May 1, 2023
@blitzjs-bot
Copy link
Contributor

Added @dbrxnds contributions for doc, code and test

@blitzjs-bot blitzjs-bot added this to Done in Toolkit May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants