Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

To add to this I had a specific scenario in mind. At @current_job they bolted on a immutable struct library and wrote validations. We are responsible for sending out renewal notices and we get the renewal price from another system. In certain scenarios we were getting back a null price and our validations dutifully caught the null and threw an exception.

Theoretically everything worked. However, the end result is (1) the customer didn't get their renewal notice and (2) we got a validation error instead of (maybe) a NPE somewhere. So what exactly are we accomplishing here is my broader point.



To be honest, this is more of a question about how best to handle errors in asynchronous event handlers (not handlers marked as async, I mean like send an email at xyz time). Imo best way to solve this is to get notified of an error in sentry, be it an NPE or validation error.

In a case where the client expects an immediate response (http GET) getting “400 validation error: foo is not allowed to be null” is a lot more meaningful than “500 Null pointer”.

In general I try not to model invalid states - less mental overhead (no one has to tell you xyz can’t be null it just cannot be null).

Ofc this is a matter of opinion and the lines get blurred as soon ad you move stuff to runtime.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: