3 ms·
> concise and elegant I would like to counter with my C++ way of doing error handling without exceptions: if (!func1()) return false; if (!func2()) re
by jackewiehose 8y ago
> concise and elegant
I would like to counter with my C++ way of doing error handling without
exceptions:
if (!func1()) return false;
if (!func2()) return false;
if (!func3())
{
err = get_error();
...
}
if (!func4()) return false;
Each function sets a global exception-like error object which can be
inspected by the caller if the function signaled an error (like
returning false in this example):
Of course you need thread local variables for this. Not sure if this is
a problem for Go or in general...
- int_19h 8y agoThis is basically errno++.