feat(errors): add typed error subclasses for each error code (#327) - #350
Merged
Lakes41 merged 1 commit intoAug 19, 2026
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Addresses #327 by introducing a dedicated typed error hierarchy rooted in
GuildPassError, providing typed subclasses for every error code defined inerrorCodes.ts.Previously, consumers had to inspect
error.codestring/enum comparisons to distinguish error types. With these changes, consumers can use idiomatic TypeScriptinstanceofchecks (e.g.,if (e instanceof NetworkError) ...) while maintaining full backward compatibility with string-based checks.Key Changes
GuildPassError): Extends JavaScript's built-inError, properly sets the prototype chain for transpiledinstanceofchecks, and provides support for HTTP status codes, structured details, causes, and JSON serialization.errorCodes.ts): Defined standard error codes and transport codes (NETWORK_ERROR,TIMEOUT_ERROR,CIRCUIT_OPEN,UPSTREAM_ERROR,INVALID_CONFIG,ACCESS_DENIED,UNAUTHORIZED,FORBIDDEN,NOT_FOUND,VALIDATION_ERROR,RATE_LIMIT_EXCEEDED,CONFLICT,INTERNAL_ERROR,CONTRACT_ERROR,INVALID_SIGNATURE,BAD_REQUEST,UNSUPPORTED, and domain not-found codes).errorTypes.ts):NetworkErrorTimeoutErrorUpstreamErrorCircuitOpenErrorInvalidConfigErrorAccessDeniedErrorUnauthorizedErrorForbiddenErrorNotFoundErrorValidationErrorRateLimitError(RateLimitExceededError)ConflictErrorInternalErrorContractErrorInvalidSignatureErrorBadRequestErrorUnsupportedErrorMembershipNotFoundError,GuildNotFoundError,PassNotFoundError@guildpass/integration-client.packages/integration-client/src/http/errors.tsandcircuitBreaker.ts.src/errors/for consumer convenience.test:runalias script to rootpackage.json.Testing
packages/integration-client/test/errors.test.jsandpackages/integration-client/test/errors.test.ts.instanceof Error,instanceof GuildPassError, andinstanceof <Subclass>behavior..codeproperties.try ... catchpattern matching usinginstanceof.pnpm typecheckacross all workspace projects (passed with 0 errors).pnpm --filter @guildpass/integration-client test(22/22 tests passing).Closes #327