File size: 708 Bytes
598f0d5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { TRPCError } from "@trpc/server";

export function throwUnauthorized(message = "Unauthorized"): never {
  throw new TRPCError({ code: "UNAUTHORIZED", message });
}

export function throwForbidden(message = "Forbidden"): never {
  throw new TRPCError({ code: "FORBIDDEN", message });
}

export function throwNotFound(resource = "Resource"): never {
  throw new TRPCError({ code: "NOT_FOUND", message: `${resource} not found` });
}

export function throwBadRequest(message = "Bad request"): never {
  throw new TRPCError({ code: "BAD_REQUEST", message });
}

export function throwInternal(message = "Internal server error"): never {
  throw new TRPCError({ code: "INTERNAL_SERVER_ERROR", message });
}