I'm building an admin dashboard app using Firestore, TypeScript, and Next.js and want to implement centralized error handling at the data level for its API methods. I plan to have a separate error handling mecanism on each level of the App.
Question:
Can I simply:
Extend the built-in Error class? Export specific error classes directly to the API methods file? Is the potential coupling risk significant at the data layer? Alternative:
Or Should I avoid the Error class entirely? Create a custom abstract error class with methods? Inject it into the API methods?
Best Practices:
Are there any recommended approaches beyond those listed above?
Can I simply:
Extend the built-in Error class? Export specific error classes directly to the API methods file? Is the potential coupling risk significant at the data layer? Alternative:
Or Should I avoid the Error class entirely? Create a custom abstract error class with methods? Inject it into the API methods?
Best Practices:
Are there any recommended approaches beyond those listed above?