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

Remove GrafastError, introduce flagError() #2036

Merged
merged 17 commits into from
May 1, 2024

Conversation

benjie
Copy link
Member

@benjie benjie commented Apr 30, 2024

In the old system, errors would be wrapped in GrafastError to make detection easier. In the new system we use bit flags to indicate an error, so we don't need this any more. This PR strips out all the GrafastError instances and replaces them with their newer equivalents (flag checks). This also means that errors can now be treated as values, and that things that are not instanceof Error can be used as errors. It also gives a new way to return explicit errors in the form of the flagError() function (alternative methods are to throw the error, or to return a rejected promise, but flagError() works in synchronous cases in the middle of a list without breaking the rest of the list).

The special value $$inhibited is no longer a symbol, it is now a FlaggedValue same as the values returned by flagError(). This is more flexible.

When trapping an error you now just get the value directly, no need for TrappedError any more (which was never published anyway)

GraphQL resolver emulation is a little more expensive now, and may not work with iterables which yield promises (only with arrays).

🚨 Breaking change: We no longer check for instanceof Error - you must use flagError() directly if you want to return an error in the middle of a list/batch synchronously. This allows errors to be treated as values (pretty important!) and also means that we don't do expensive instanceof checks which should help performance, perhaps.

Copy link

changeset-bot bot commented Apr 30, 2024

🦋 Changeset detected

Latest commit: 099d1db

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

This PR includes changesets to release 15 packages
Name Type
grafast Patch
@localrepo/grafast-bench Patch
@dataplan/json Patch
@dataplan/pg Patch
@grafserv/persisted Patch
grafserv Patch
ruru-components Patch
@localrepo/grafast-website Patch
graphile-build-pg Patch
graphile-build Patch
graphile-utils Patch
pgl Patch
postgraphile Patch
graphile-export Patch
graphile 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

@benjie benjie merged commit 9e14496 into main May 1, 2024
24 checks passed
@benjie benjie deleted the remove-old-grafast-error-instances branch May 1, 2024 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

1 participant