Error vs. Exception

From HaskellWiki
Revision as of 22:55, 5 December 2009 by Lemming (talk | contribs) (introduction and sketch)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

There is confusion about the distinction of errors and exceptions for a long time, repeated threads in Haskell-Cafe and more and more packages that handle errors and exceptions or something between. Although both terms are related and sometimes hard to distinguish, it is important to do it carefully. This is like the confusion between parallelism and concurrency.

The first problem is that exception seem to me to be the historically younger term. Before there were only errors, independent from whether they are programming or I/O or user errors. In this article we want to use the term "exception" for expected but irregular situations at runtime and the term "error" for mistakes in the running program, that can be resolved only by fixing the program.

The history may have led to the identifiers we find today in the Haskell language and standard Haskell modules.

  • Exceptions: Control.Exception.try, Control.Exception.catch, IOError, Control.Monad.Error
  • Errors: error, Prelude.catch, Debug.Trace.trace

Prelude.catch vs. Control.Exception.catch

Even more confusion was initiated by Java programming language to use the term "exceptions" for programming errors like the NullPointerException.

error handling = debugging


examples: GHC errors and exceptions

Bruker library

Modula-3 arithmetic library

When exceptions become errors

unhandled exceptions

When errors become exceptions

web servers

See also