Skip to content
Back to skills

Orpc Client Error Handling

ASecurity

Handle errors in a type-safe way in oRPC clients.

  • 8 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 12, 2026
toolsgit

Works with

  • cli

Security analysis

A100/100

Scanned September 12, 2026

npx -y skills add ali-master/skills --skill orpc-client-error-handling --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Orpc Client Error Handling?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Orpc Client Error Handling
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ali-master-orpc-client-error-handling/badge)](https://www.skillsdirectory.com/skills/ali-master-orpc-client-error-handling)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: oRPC Client Error Handling
description: Handle errors in a type-safe way in oRPC clients.
license: MIT
metadata:
  author: Ali Torki
  homepage: https://github.com/ali-master
  version: "1.0.0"
---

# Error Handling in oRPC Clients

Handle type-safe errors in oRPC clients using [type-safe error handling](/docs/error-handling#type‐safe-error-handling).

## Using `safe` and `isDefinedError`

```ts
import { isDefinedError, safe } from '@orpc/client'

const doSomething = os
  .input(z.object({ id: z.string() }))
  .errors({
    RATE_LIMIT_EXCEEDED: {
      data: z.object({ retryAfter: z.number() })
    }
  })
  .handler(async ({ input, errors }) => {
    throw errors.RATE_LIMIT_EXCEEDED({ data: { retryAfter: 1000 } })
  })
  .callable()

const [error, data, isDefined] = await safe(doSomething({ id: '123' }))
// or { error, data, isDefined } = await safe(...)

if (isDefinedError(error)) { // or `isDefined`
  // handle known error
  console.log(error.data.retryAfter)
} else if (error) {
  // handle unknown error
} else {
  // handle success
  console.log(data)
}
```

- `safe` works like try/catch but infers error types
- `isDefinedError` checks if an error came from `.errors`
- `isDefined` can replace `isDefinedError`

## Safe Client

`createSafeClient` wraps all procedure calls with `safe`:

```ts
import { createSafeClient } from '@orpc/client'

const safeClient = createSafeClient(client)

const [error, data] = await safeClient.doSomething({ id: '123' })
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.