Catch Drizzle Error

Is there any way to handle errors that drizzle throws gracefully? In the code that I provided, the query return Project or undefined, however if the query doesnt executed succesfully (it doesnt find an entry), it goes into the catch block and my not found error never fires. How can I distinguish what type of errors drizzle is throwing so that I can throw the the right type of error?
No description
2 Replies
DunnO
DunnOOP7mo ago
Okay i figured I can check the type of the error in the catch block then throw the respective error. But I still need to check 'if (!project)' so that i dont get an error when returning project. I also have to define project as 'Project | Undefined' since that is the return type of the query.
No description
DunnO
DunnOOP7mo ago
Okay I found a solution to that, not sure if it is okay or if this is the best way i can get around it.
No description
Want results from more Discord servers?
Add your server