app-error-model
Browser-safe public application error definitions shared by contracts, clients, and backend error handling.
The package exports canonical error codes, metadata schemas, descriptions, names, and numeric HTTP statuses. It has no backend runtime dependencies.
API
appErrorDefinitions: every public error code and its metadata.- Metadata schemas:
validationErrorMetadataSchema,resourceNotFoundErrorMetadataSchema,resourceConflictErrorMetadataSchema,rateLimitExceededErrorMetadataSchema, and the others with theErrorMetadataSchemasuffix. - Types:
AppErrorCode,AppErrorMetadata.
Codes
RATE_LIMIT_EXCEEDED (429) is returned when rate-limit refuses a call. Its metadata is { cause: string } (RateLimitExceededErrorMetadata). The Retry-After header carries the wait time.
RESOURCE_CONFLICT (409) is returned when the resource exists but its state refuses the operation. Its metadata is
{ cause: string, resource: string } (ResourceConflictErrorMetadata), for example { cause: "already_full", resource: "squad" }. cause
stays an open string so a product can add its own; resourceConflictReasonSchema (ResourceConflictReason) names the
stack's own: already_member, already_owner, invite_expired, invite_used, last_owner.
Commands
pnpm nx run app-error-model:typecheck # type-check the package
pnpm nx run app-error-model:test # run the Vitest suite