fix: improve error handling in tRPC API handler for better logging in development
This commit is contained in:
parent
467933299e
commit
ece58b7c3b
1 changed files with 9 additions and 8 deletions
|
|
@ -8,14 +8,15 @@ import { createTRPCContext } from "~/server/api/trpc";
|
|||
export default createNextApiHandler({
|
||||
createContext: createTRPCContext,
|
||||
|
||||
onError:
|
||||
env.NODE_ENV === "development"
|
||||
? ({ path, error }) => {
|
||||
onError: ({ path, error }) => {
|
||||
if (env.NODE_ENV === "development") {
|
||||
console.error(
|
||||
`❌ tRPC failed on ${path ?? "<no-path>"}: ${error.message}`,
|
||||
`❌ tRPC failed on ${path ?? "<no-path>"}, msg: ${error.message}`,
|
||||
);
|
||||
}
|
||||
: undefined,
|
||||
|
||||
console.error(error);
|
||||
},
|
||||
router: appRouter,
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue