Tagged with

Error Handling

Functions Returning True on Success

Many beginning programmers latch on to the idea of having functions return True if they succeed and False if they fail so that you have code like this:

if do_something():
    # It worked!
    logger.error("Something didn't work!")

For me, I think it was when I saw some …

Why Exceptions Are Better Than Returned Error Codes

I'm occasionally surprised that some programmers prefer an error handling system of returned error codes over exceptions. After spending several years with both approaches, I've become convinced that exceptions are a superior model. If you agree, great! If not, read on and let me try to persuade you. I'm always …