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

fix: server$ error handling #7185

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

DustinJSilk
Copy link
Contributor

@DustinJSilk DustinJSilk commented Dec 20, 2024

What is it?

  • Bug

Description

This fixes a few issues with server$ error handling

  • 4xx ServerErrors are returning a a value instead of throwing an error on the frontend
  • server$ middleware could not catch errors - the server$ function would simply exit early. [🐞] server$ middleware cannot catch errors #7183
  • You can now also throw a ServerError in a routeLoader$ to change the status code and return some serialised data. This is simply an added bonus but should pave the way for more standardised errors across loaders, actions, and server$ functions

Checklist

  • My code follows the developer guidelines of this project
  • I performed a self-review of my own code
  • I added a changeset with pnpm change <--- this doesn't work?
  • I made corresponding changes to the Qwik docs
  • I added new tests to cover the fix / functionality

@DustinJSilk DustinJSilk requested a review from a team as a code owner December 20, 2024 14:51
Copy link

changeset-bot bot commented Dec 20, 2024

⚠️ No Changeset found

Latest commit: 8c01bb5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@DustinJSilk
Copy link
Contributor Author

I get this error when running pnpm change: Failed to find where HEAD diverged from origin/upcoming. Does origin/upcoming exist?

@DustinJSilk
Copy link
Contributor Author

I would add a fix for this: #7165, but i have no idea how to fix it.

@DustinJSilk
Copy link
Contributor Author

@wmertens fyi - returning errors as values was intentional in this PR: #6290.
I dont think this was the right decision, as it becomes really difficult to work with. Now, errors behave like javascript errors and the user can catch them and use a type guard on the data instead.

@DustinJSilk
Copy link
Contributor Author

@shairez any chance we can get this PR reviewed?

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.

1 participant