GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||
GeezerVison is showing github.com — feat(errors): Recognize Feathers errors across duplicate module copies by fratzinger · Pull Request #3726 · feathersjs/feathers Conversation
Member
Summary
const FEATHERS_ERROR = Symbol.for('feathers.error')
class FeathersError extends Error {
+ static [Symbol.hasInstance]<T>(this: abstract new (...args: any[]) => T, value: unknown): value is T
+ prototype chain matches → true
+ no string brand on value → false
+ this === FeathersError → true
+ this === built-in class for brand → true // NotFound only matches 'NotFound'
constructor(...)
...
+ Object.defineProperty(this, FEATHERS_ERROR, { value: name }) // non-enumerable
}Plus an explicit, typed guard: isFeathersError(error) // error is FeathersError isFeathersError(error, 'NotFound') // error is NotFound isFeathersError(error, 404) // error is NotFound isFeathersError(error, 418) // type error
EvidenceThe new test loads a second module instance via const duplicate = await import('../src/errors.js') const error = new duplicate.NotFound() error instanceof errors.FeathersError // true error instanceof errors.NotFound // true error instanceof errors.BadRequest // false errors.isFeathersError(error, 404) // true
Merge DangerDoor: two-way The change adds to the public API ( Blast Radius: low
🤖 Generated with Claude Code
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions`instanceof FeathersError` fails when multiple versions of feathers are
installed or CommonJS and ES modules are mixed. Feathers errors are now
branded with a global `Symbol.for('feathers.error')` and the error
classes implement `Symbol.hasInstance`, so `instanceof` works across
module copies while still narrowing to the specific error type.
Also adds a typed `isFeathersError(error, type?)` guard that accepts an
error name or status code, and adds the missing `Gone` entries to
`errors` and the `Errors` interface.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
daffl
reviewed
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I understand what this is for. From what I know
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsThis branch has not been deployedNo deployments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ReviewersUh oh!
There was an error while loading. Please reload this page. AssigneesNo one assignedLabels
None yet
ProjectsMilestoneNo milestoneDevelopmentSuccessfully merging this pull request may close these issues. Uh oh!
There was an error while loading. Please reload this page. Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later. | ||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |