2 ms·
My dogma around this sort of pattern is similar, except that I don't just use one global error catching statement. Basically, every module or function or whate
by osdiab 9y ago
My dogma around this sort of pattern is similar, except that I don't just use one global error catching statement.
Basically, every module or function or whatever has a client. Sometimes those clients are other parts of your own system, sometimes they're end users outside of your control. Regardless, at significant barriers of abstraction, I try to catch errors, and translate them into new error types/representations that would be relevant or actionable by the intended client of that code, with the original error provided as a member. If you follow this pattern, the logic you write is free of error handling code, error handling code is centralized at abstraction barriers, and at any point you should have few errors that you wouldn't know how to respond to and probably just give up and bubble to the top.