3 ms·
I have a pattern that's working really well for us in the codebase, which I call `recover`. Anywhere where you're tempted to crash because it's not possible, I
by pbiggar 7y ago
I have a pattern that's working really well for us in the codebase, which I call `recover`.
Anywhere where you're tempted to crash because it's not possible, I add
recover debug_string debug_values return_value
Recover prints a stack trace, notifies Rollbar, and then continues with the return value. As a result, we see whatever is going wrong with the code, but the program doesn't crash on users. And since we're using OCaml (strongly typed), we end up having decent guarantees of safety.
Works pretty well for us.
- Fronzie 7y agoThis sounds similar to C++'s exception-mechanism, on which the C++ community seems split on whether it's good or not. Are they any noteworthy differences?
- pbiggar 7y agoAll error handling is fundamentally the same. I think this one is as far from exception handling as possible while still being error handling.