Skip to content
Back to skills

Orpc No Throw Literal

ASecurity

Always throw Error instances instead of literal values.

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

Works with

  • cli

Security analysis

A100/100

Scanned September 12, 2026

npx -y skills add ali-master/skills --skill orpc-no-throw-literal --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Orpc No Throw Literal?

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

Security grade badge for Orpc No Throw Literal
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ali-master-orpc-no-throw-literal/badge)](https://www.skillsdirectory.com/skills/ali-master-orpc-no-throw-literal)

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 No Throw Literal
description: Always throw Error instances instead of literal values.
license: MIT
metadata:
  author: Ali Torki
  homepage: https://github.com/ali-master
  version: "1.0.0"
---

# No Throw Literal

In JavaScript, you can throw any value, but it's best to throw only `Error` instances.

```ts
// eslint-disable-next-line no-throw-literal
throw 'error' // ✗ avoid
throw new Error('error') // ✓ recommended
```

> oRPC treats thrown `Error` instances as best practice, as recommended by [JavaScript Standard Style](https://standardjs.com/rules.html#throw-new-error-old-style).

## Configuration

Customize behavior by setting `throwableError` in the `Registry`:

```ts
declare module '@orpc/server' { // or '@orpc/contract', '@orpc/client'
  interface Registry {
    throwableError: Error
  }
}
```

> Avoid `any`/`unknown` for `throwableError` because it prevents the client from inferring type-safe errors. Use `null | undefined | {}` (equivalent to `unknown`) for stricter inference.

> If you configure `throwableError` as `null | undefined | {}`, check `isSuccess` instead of `error`:

```ts
const { error, data, isSuccess } = await safe(client('input'))

if (!isSuccess) {
  if (isDefinedError(error)) {
    // handle type-safe error
  }
} else {
  // handle success
}
```

## Bonus

Enable the ESLint [no-throw-literal](https://eslint.org/docs/rules/no-throw-literal) rule.

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.