Exceptions

This lesson gives a brief introduction to exceptions.

We'll cover the following

Exceptions #

Unexpected situations are part of programs: user mistakes, programming errors, changes in the program environment, etc. Programs must be written in ways to avoid producing incorrect results when faced with exceptional conditions.

Some of these conditions may be severe enough to stop the execution of the program. For example, a required piece of information may be missing or invalid or a device may not be functioning correctly. The exception handling mechanism of D helps with stopping program execution when necessary and recover from unexpected situations when possible.

As an example of a severe condition, we can think of passing an unknown operator to a function that knows only the four arithmetic operators.

Get hands-on with 1400+ tech skills courses.