there has to be a better way. the error code checking sounds a little too manual for a modern language imho.
[1]: http://www.sics.se/~joe/thesis/armstrong_thesis_2003.pdf
I'm toying about a new languagte where each function have IN/OUT/ERR channels.
So, is possible to do:
result | err = open('file)
This consume the ERR channel, however, if is not:
result = open('file')
it "trow". Inside the open, any raise is like a return for the ERR channel.
This combined with RAII & scope like in D: http://dlang.org/exception-safe.html
For example, Option types...