( find: () => Promise<T | null | undefined> | undefined, message: string, )
| 1 | import { TRPCError } from '@trpc/server'; |
| 2 | |
| 3 | export 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 | } |
no outgoing calls
no test coverage detected