No Throw Literal
In JavaScript, you can throw any value, but it’s best to throw only Error instances.
// eslint-disable-next-line no-throw-literal
throw 'error' // ✗ avoid
throw new Error('error') // ✓ recommended
Configuration
Customize oRPC’s behavior by setting ThrowableError in the Registry:
declare module '@orpc/server' { // or '@orpc/contract', or '@orpc/client'
interface Registry {
ThrowableError: Error
}
}
Bonus
If you use ESLint, enable the no-throw-literal rule to enforce throwing only Error instances.