This commit is contained in:
David Nguyen
2025-02-04 22:25:11 +11:00
parent 381a9d3fb8
commit 540cc5bfc1
35 changed files with 529 additions and 890 deletions

View File

@ -1,6 +1,7 @@
import type { ErrorHandlerOptions } from '@trpc/server/unstable-core-do-not-import';
import { AppError, AppErrorCode } from '@documenso/lib/errors/app-error';
import { env } from '@documenso/lib/utils/env';
import { buildLogger } from '@documenso/lib/utils/logger';
const logger = buildLogger();
@ -10,8 +11,10 @@ export const handleTrpcRouterError = (
{ error, path }: Pick<ErrorHandlerOptions<undefined>, 'error' | 'path'>,
source: 'trpc' | 'apiV1' | 'apiV2',
) => {
// Always log the error for now.
console.error(error);
// Always log the error on production for now.
if (env('NODE_ENV') !== 'development') {
console.error(error);
}
const appError = AppError.parseError(error.cause || error);