Theo's Typesafe CultTTC
Theo's Typesafe Cult2y ago
5 replies
DJB160

What's the best way to pass up to the frontend that my database in currently inaccessible?

t3 + trpc + primsa + Next14 + server components combo.

I'm just trying to make my backend a little more robust. Assuming I've turned off my database in order to simulate issues. Currently I get a standard error. I'd like to pass this back you to the frontend as a more friendly "There was a problem with the Database. Please try again later" type message.

src\trpc\server.ts catches the error just fine at....

.catch((cause: TRPCErrorResponse) => {
observer.error(TRPCClientError.from(cause));
});

Is there an established, or recommended, way to to best catch and pass this up to frontend page? I see the page uses TRPC Subscriptions/observable. Should I be modifying the default T3 provided code here?
Solution
if(!healthy){
// do something
}
Was this page helpful?