Throwing something other than `Unexpected token '<', "<!DOCTYPE "... is not valid JSON`
I'm trying to do custom error handling but whatever I throw just ends up being `Unexpected token '<', "<!DOCTYPE "... is not valid JSON``
Am I doing something weird here?
11 Replies
Yes you aren’t hitting the tRPC endpoint
I am though, I can debug through the entire thing -> then something weird happens after throwing from inside
What does the response say?
Solution
I solved it through returning the error locally instead of throwing it
i'm curious what happened here. If you're hitting trpc endpoint, trpc doesnt return html afaik. Or does it?
Is this only happening in production/client? cloudflare/firewalls can return html page. Other than obviously the nextjs 404 page, which would mean youre indeed not hitting the endpoint
I think that what happened is that when I throw the error the endpoint either returns null or nothing at all
Umm. That wouldnt be
Unexpected token '<', "<!DOCTYPE "... is not valid JSON
tho. idkthis was the code previous
yeah you're right, tried to find the argument to the JSON.parse that causes the bug but post throwing it's hard to follow
@Samuel Barnholdt did you fix the issue i got similar issues
@Aadarsha