Articles tagged with Error Handling

Functions Returning True on Success

By Eric — 3 minute read

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!
    do_some_other_stuff()
else:
    logger.error("Something didn't work!")

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

Read more...

Why Exceptions Are Better Than Returned Error Codes

By Eric — 3 minute read

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 …

Read more...