Exceptions

An exception is a state a program enters when it encounteres an erroneous situation. Two examples are number overflow and invalid operands. When an exception occurs, the processor stops executing the program and notifies the user either directly or indirectly that it cannot continue. In other words, if an exception occurs, the program failed. It failed in a way that means there the programmer made a misstake when writing the program. Exceptions do not occur in correctly written programs.

For more information on Exception relaxation, see Exception Relaxation.

Types

  • Overflow
  • Invalid operand
  • Out of bounds
  • Unassigned
  • Unable to allocate
  • Unable to deallocate

Overflow

Occurs when the result is outside the bounds of the number type.

Invalid operand

Occurs when an argument to an operation does not make sense for that operation.

Out of bounds

Occurs when a variable of array type is accessed outside the array bounds.

Unassigned

Occurs when an a variable has not been assigned a value.

Unable to allocate

Occurs when an allocation could not complete.

Unable to deallocate

Occurs when a deallocation could not complete.