When error in tRPC route, the error message is vauge
There are no line numbers when a runtime error happens in a tRPC route. Surely I am missing something? Would be impossible to debug larger apps.
9 Replies
Could you share repo for reproduction?
Just need a route that has a runtime error in it. for eg const arr = []; console.log(arr[0]); this will produce a runtime error
That example with the console would just print undefined as it should, but if I do something like:
It gives me
Magic number procedure error
on the client side. I'm using this setup. It has no additional error formatting.GitHub
GitHub - tsoos99dev/trpc-next-app-dir-minimal
Contribute to tsoos99dev/trpc-next-app-dir-minimal development by creating an account on GitHub.
I can print the stack trace locally:
To get:
Which includes the line number.
Error Handling | tRPC
Whenever an error occurs in a procedure, tRPC responds to the client with an object that includes an "error" property. This property contains all the information that you need to handle the error in the client.
Does that answer your questions?
@cadams how are you even getting those messages printed? Is there an
onError
formatter set up on the server?looks like you are using create-t3-app, and by default it sets a onError handler
yes it thank you !
ag i see, thank you !