I’m building a Node.js backend (using Express + TypeScript) and I want to implement a clean, scalable, SOLID-friendly error handling system.
My goal is:
Developer Side: Print a detailed error log in the console (stack trace, metadata, etc.).
Client Side: Return a safe, formatted error response without exposing sensitive details.
I also use Prisma ORM, and when I checked their documentation, there are a huge number of Prisma-specific error codes. It’s not possible to manually handle every single one, especially since Prisma isn’t the only tool in my stack.
So my questions are:
- How can I send different errors to developers and users cleanly?
I want an error-handling approach that is scalable, maintainable, and clean, rather than manually checking hundreds of error types.