#How to handle throw error on server component?

4 messages · Page 1 of 1 (latest)

hazy apex
#

On production build, error.tsx has no original error information, just

An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.

but i need the original message for handling it, such as Unauthorized, forbidden, etc

icy briarBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

hazy apex
#

i calling trpc on server component

azure fog
# hazy apex On production build, error.tsx has no original error information, just An erro...

errors can contain sesitive information. Because of that they are visible in development but not in production. You can take a look at this guide on what you need to change to display the actual error: https://joulev.dev/blogs/throwing-expected-errors-in-react-server-actions

TL;DR
Build a proper error handling system or use an existing one. I like to use https://next-safe-action.dev/

This example guides are for server actions. You can use the same system for serverside errors