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 }...
Jump to solution
3 Replies
Neto
Neto•5mo ago
make a first query or context populated from server component
Solution
Neto
Neto•5mo ago
if(!healthy){ // do something }
DJB160
DJB160OP•5mo ago
Your suggestion works. For some reason I overcomplicated my thinking here 🙂
Want results from more Discord servers?
Add your server