Skip to content

Exception

Ben Christel edited this page Jun 27, 2022 · 1 revision

Eric Lippert classifies exceptions into fatal, boneheaded, vexing, and exogenous.

  • fatal: the exception will kill your process and there's nothing you can do (e.g. out of memory)
  • boneheaded: a programmer goofed, and something totally preventable went wrong. Usually a sign of bad design. I like to use AlgebraicTypes to rule out boneheaded exceptions at compile time.
  • vexing: a Routine threw an exception even though the error case is a totally expected one. This is a design smell. It's usually more civilized for the routine to signal the error some other way, e.g. Optional<T>. Parsers often throw vexing exceptions.
  • exogenous: the error originates from another Process or Service outside your control.

I rather like this scheme—with one addition: exogenous errors should not be handled by domain code, since they originate from infrastructure. See CheckedException.

Clone this wiki locally