Exceptions: Advantages of Exceptions

Advantages of Exceptions

  • Advantage 1: Separating Error-Handling Code from "Regular" Code. Exceptions provide the means to separate the details of what to do when something out of the ordinary happens from the main logic of a program. In traditional programming, error detection, reporting, and handling often lead to confusing spaghetti code.
  • Advantage 2: Propagating Errors Up the Call Stack. A second advantage of exceptions is the ability to propagate error reporting up the call stack of methods.
  • Advantage 3: Grouping and Differentiating Error Types. Because all exceptions thrown within a program are objects, the grouping or categorizing of exceptions is a natural outcome of the class hierarchy.

Related concepts

Advantages of Exceptions

Exceptions: Advantages of Exceptions — Structure map

Clickable & Draggable!

Exceptions: Advantages of Exceptions — Related pages: