Skip to content

feat!: end-to-end typesafe error handling, remove @orpc/react and @orpc/next#77

Merged
dinwwwh merged 38 commits intomainfrom
feat/contract/typesafe-error-handling
Jan 10, 2025
Merged

feat!: end-to-end typesafe error handling, remove @orpc/react and @orpc/next#77
dinwwwh merged 38 commits intomainfrom
feat/contract/typesafe-error-handling

Conversation

@dinwwwh
Copy link
Copy Markdown
Member

@dinwwwh dinwwwh commented Jan 9, 2025

const createPost = os
  .errors({
    CONFLICT: {
      data: z.object({
        why: z.string(),
      }),
    },
  })
  .handler(({ errors }) => {
    throw errors.CONFLICT({ data: { why: 'some reason' } })
  })

const [data, error] = await safe(createPost({ title: 'title' }))

if (error && isDefinedError(error)) {
  const data = error.data // { why: 'some reason' } full typed data
}

const mutation = useMutation(orpc.createPost.mutationOptions({
  onError(error) {
    if (isDefinedError(error)) {
      const data = error.data // { why: 'some reason' } full typed data
    }
  },
}))
  • Removed @orpc/react since it was too complicated to maintain, while @orpc/react-query is simpler and easier to maintain while achieve the same functionality.
  • Temporarily removed @orpc/next due to unexpected behavior from Next.js. You can follow progress here. I will bring this package back in a future oRPC version.

@vercel
Copy link
Copy Markdown

vercel Bot commented Jan 9, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
orpc ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 10, 2025 0:56am

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jan 9, 2025

Open in Stackblitz

More templates

@orpc/client

npm i https://pkg.pr.new/@orpc/client@77

@orpc/contract

npm i https://pkg.pr.new/@orpc/contract@77

@orpc/react-query

npm i https://pkg.pr.new/@orpc/react-query@77

@orpc/openapi

npm i https://pkg.pr.new/@orpc/openapi@77

@orpc/server

npm i https://pkg.pr.new/@orpc/server@77

@orpc/shared

npm i https://pkg.pr.new/@orpc/shared@77

@orpc/vue-colada

npm i https://pkg.pr.new/@orpc/vue-colada@77

@orpc/vue-query

npm i https://pkg.pr.new/@orpc/vue-query@77

@orpc/zod

npm i https://pkg.pr.new/@orpc/zod@77

commit: 4a098f1

@dinwwwh dinwwwh changed the title feat(contract): end-to-end typesafe error handling feat(contract)!: end-to-end typesafe error handling, remove @orpc/react and @orpc/next Jan 10, 2025
@dinwwwh dinwwwh changed the title feat(contract)!: end-to-end typesafe error handling, remove @orpc/react and @orpc/next feat!: end-to-end typesafe error handling, remove @orpc/react and @orpc/next Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant