Always throw Error instances instead of literal values.
Scanned 9/12/2026
Install to Claude Code
npx -y skills add ali-master/skills --skill orpc-no-throw-literal --agent claude-codeInstalls 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 automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/ali-master-orpc-no-throw-literal)More formats (shields.io, HTML) on the badges page.
---
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.
Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.
No comments yet. Be the first to comment!