Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Handling errors as exceptions

  • Only need to explicitly check for it at the level where we know what to do with the problem.
  • But: Do we want our pacemaker to stop totally after missing one beat? Probably not. Or better yet: not when it is in production.
main()
    ...
    try:
        ...
        result = do_something(filename)
        do_something_else(result)
    except Exception:
        decide_what_to_do()

    always_happens()