MCPcopy Create free account
hub / github.com/AnswerOverflow/AnswerOverflow / findOrThrowNotFound

Function findOrThrowNotFound

packages/api/src/utils/operations.ts:3–10  ·  view source on GitHub ↗
(
	find: () => Promise<T | null | undefined> | undefined,
	message: string,
)

Source from the content-addressed store, hash-verified

1import { TRPCError } from '@trpc/server';
2
3export async function findOrThrowNotFound<T>(
4 find: () => Promise<T | null | undefined> | undefined,
5 message: string,
6) {
7 const data = await find();
8 if (!data) throw new TRPCError({ code: 'NOT_FOUND', message });
9 return data;
10}

Callers 3

protectedFetchFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected