Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Error handling alternatives #465

Discussion options

You must be logged in to vote

Ah, yes that's true... Thanks for the explanation. I put together an inbetween solution just so that I can map from my own errors to oRPC ones even when just calling actionables straight up. Here's what I came up with if anyone is interested:

Custom error -> oRPC error
// errors.ts
import type { ORPCErrorConstructorMap } from '@orpc/server';
import type { ApplicationError } from '@saas/errors';
import {
  FeatureRestrictionError,
  ForbiddenError,
  NotFoundError,
  UnauthenticatedError,
} from '@saas/errors';
import { z } from 'zod';

type ErrorMap = Record<string, { data?: z.ZodSchema }>;

export const orpcErrors = {
  NOT_FOUND: {},
  FORBIDDEN: {},
  UNAUTHENTICATED: {},
  FEATURE_RE…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@ludwigbacklund
Comment options

@unnoq
Comment options

unnoq May 4, 2025
Maintainer

@unnoq
Comment options

unnoq May 4, 2025
Maintainer

@ludwigbacklund
Comment options

Answer selected by unnoq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants