Skip to content

Commit

Permalink
feat: Add support for HTTP status 422 (Unprocessable Content) (#4080)
Browse files Browse the repository at this point in the history
  • Loading branch information
mozzius committed Mar 27, 2023
1 parent a82dec7 commit facbeea
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/server/src/http/getHTTPStatusCode.ts
Expand Up @@ -22,6 +22,7 @@ const JSONRPC2_TO_HTTP_CODE: Record<
PRECONDITION_FAILED: 412,
PAYLOAD_TOO_LARGE: 413,
METHOD_NOT_SUPPORTED: 405,
UNPROCESSABLE_CONTENT: 422,
TOO_MANY_REQUESTS: 429,
};

Expand Down
1 change: 1 addition & 0 deletions packages/server/src/rpc/codes.ts
Expand Up @@ -31,6 +31,7 @@ export const TRPC_ERROR_CODES_BY_KEY = {
CONFLICT: -32009, // 409
PRECONDITION_FAILED: -32012, // 412
PAYLOAD_TOO_LARGE: -32013, // 413
UNPROCESSABLE_CONTENT: -32022, // 422
TOO_MANY_REQUESTS: -32029, // 429
CLIENT_CLOSED_REQUEST: -32099, // 499
} as const;
Expand Down
1 change: 1 addition & 0 deletions www/docs/server/error-handling.md
Expand Up @@ -42,6 +42,7 @@ tRPC defines a list of error codes that each represent a different type of error
| PRECONDITION_FAILED | Access to the target resource has been denied. | 412 |
| PAYLOAD_TOO_LARGE | Request entity is larger than limits defined by server. | 413 |
| METHOD_NOT_SUPPORTED | The server knows the request method, but the target resource doesn't support this method. | 405 |
| UNPROCESSABLE_CONTENT | The server understands the request method, and the request entity is correct, but the server was unable to process it. | 422 |
| TOO_MANY_REQUESTS | The rate limit has been exceeded or too many requests are being sent to the server. | 429 |
| CLIENT_CLOSED_REQUEST | Access to the resource has been denied. | 499 |
| INTERNAL_SERVER_ERROR | An unspecified error occurred. | 500 |
Expand Down

3 comments on commit facbeea

@vercel
Copy link

@vercel vercel bot commented on facbeea Mar 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

www – ./www

www-git-main-trpc.vercel.app
www-trpc.vercel.app
alpha.trpc.io
www.trpc.io
trpc.io
beta.trpc.io

@vercel
Copy link

@vercel vercel bot commented on facbeea Mar 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

og-image – ./www/og-image

og-image-git-main-trpc.vercel.app
og-image-three-neon.vercel.app
og-image-trpc.vercel.app
og-image.trpc.io

@vercel
Copy link

@vercel vercel bot commented on facbeea Mar 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

next-prisma-starter – ./examples/next-prisma-starter

next-prisma-starter-git-main-trpc.vercel.app
nextjs.trpc.io
next-prisma-starter-trpc.vercel.app

Please sign in to comment.