Actionable Exceptions

Avishai Ish-Shalom (@nukemberg)

Exceptions are normal

"Normal exception"

By definition, exceptions are not normal

  • Business errors
  • System errors
  • Exceptions

Either you thought it could happen, or you didn't

Exceptions are

events

Exceptions are designed to crash & burn

  • Crash your thread
  • Crash your program
  • Inconsistent state
# cv = threading.Condition()
cv.acquire()
worker = Worker()
logger.debug("Starting work")

try:
    worker.do_something()
finally:
    cv.notify_all()

Spot the bug

Like "goto" but worse

  • Can be thrown from anywhere
  • Hard to track
  • Hard to cleanup resources
  • Heavyweight, slow

Exception are abused

Exceptions should be

Actionable

Every exception should result in a code or infrastructure change

If it's not

actionable,

It's

noise

Actionable Exceptions

By Avishai Ish-Shalom

Actionable Exceptions

So that exception I see in the logs 3000 times is a "normal exception"? How exceptions are abused and how you should avoid it.

  • 10,587