3 ms·
My opinion: Exceptions are sometimes good for things going totally wrong, like connection failures or disk full. What I don't like is that it is a pretty big (
by sandreas 2y ago
My opinion:
Exceptions are sometimes good for things going totally wrong, like connection failures or disk full. What I don't like is that it is a pretty big (and sometimes slow) concept that is often misused as 'message bus'.
However, error codes are quite limited and often are an extra load besides the necessary return value, requiring reference or out params.
The best concept i know of is rust style error handling, wrapping returns via generics providing a success and an error type. This is very specific, doesn't lose context, pretty quick and still elegant to handle. There are also libraries using this style in other languages, e.g. C#[1], but it does not work everywhere.
1: https://github.com/gnaeus/OperationResult https://github.com/gnaeus/OperationResult