orpc-error-handling
Manage errors in oRPC using both traditional and type-safe strategies.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Manage errors in oRPC using both traditional and type-safe strategies.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Quick reference for Better Notify configuration, patterns, and common gotchas
Interactive setup wizard for adding Better Notify to a TypeScript/JavaScript project
Context and API guidance for Better Notify — end-to-end typed notification infrastructure for Node.js
Seamlessly use AI SDK inside your oRPC projects without any extra overhead.
Use oRPC inside an Astro project.
Functions to encode and decode base64url strings (URL-safe variant of base64).
| name | oRPC Error Handling |
| description | Manage errors in oRPC using both traditional and type-safe strategies. |
| license | MIT |
| metadata | {"author":"Ali Torki","homepage":"https://github.com/ali-master","version":"1.0.0"} |
oRPC offers a robust error handling system. You can throw standard JavaScript errors or use the specialized ORPCError class.
The
ORPCError.dataproperty is sent to the client. Avoid including sensitive information.
const rateLimit = os.middleware(async ({ next }) => {
throw new ORPCError('RATE_LIMITED', {
message: 'You are being rate limited',
data: { retryAfter: 60 }
})
return next()
})
const example = os
.use(rateLimit)
.handler(async ({ input }) => {
throw new ORPCError('NOT_FOUND')
throw new Error('Something went wrong') // → INTERNAL_SERVER_ERROR
})
import { os } from '@orpc/server'
import * as z from 'zod'
const base = os.errors({
RATE_LIMITED: {
data: z.object({ retryAfter: z.number() }),
},
UNAUTHORIZED: {},
})
const rateLimit = base.middleware(async ({ next, errors }) => {
throw errors.RATE_LIMITED({
message: 'You are being rate limited',
data: { retryAfter: 60 }
})
return next()
})
const example = base
.use(rateLimit)
.errors({
NOT_FOUND: { message: 'The resource was not found' },
})
.handler(async ({ input, errors }) => {
throw errors.NOT_FOUND()
})
When you throw an ORPCError and code, status, and data match a defined error, oRPC treats it as if you used errors.[code].
const rateLimit = base.middleware(async ({ next, errors }) => {
// Both are equivalent:
throw errors.RATE_LIMITED({ data: { retryAfter: 60 } })
throw new ORPCError('RATE_LIMITED', { data: { retryAfter: 60 } })
return next()
})