porsager / postgres

Postgres.js - The Fastest full featured PostgreSQL client for Node.js, Deno, Bun and CloudFlare
The Unlicense
7.39k stars 267 forks source link

Global error handler #758

Open EDjur opened 9 months ago

EDjur commented 9 months ago

Hi!

First off, thanks a lot for this great project!

I have a use case where I want to be able to catch any errors thrown by my sql client globally. I've tried making a wrapper but had some issues with NOT_TAGGED_CALL errors.

Best case, there would be some onError callback in the options passed to the client initialisation. But barring that, is there any other way to catch errors globally for the sql client instead of sprinkling try/catch around every single query?

Thank you! 🙏