Skip to content

Instantly share code, notes, and snippets.

@dahnielson
Created July 29, 2010 11:55
Show Gist options
  • Save dahnielson/497925 to your computer and use it in GitHub Desktop.
Save dahnielson/497925 to your computer and use it in GitHub Desktop.
Standard exceptions

Exceptions

  • std::exception
    • std::bad_alloc thrown by new on allocation failure.
    • std::bad_cast thrown by dynamic_cast when fails with a referenced type.
    • std::bad_exception thrown when an exception type doesn't match any catch.
    • std::bad_typeid thrown by typeid.
    • std::logic_error thrown by logic errors, represent problems in the internal logic of a program; in theory, these are preventable, and even detectable before the program runs.
      • std::domain_error thrown by the library, or by you, to report domain errors (domain in the mathmatical sense).
      • std::invalid_argument thrown to report invalid arguments to functions.
      • std::length_error thrown when an object is constructed that would exceed its maximum permitted size.
      • std::out_of_range this represents an argument whose value is not within the expected range.
    • std::runtime_error thrown by runtime errors, represent problems outside the scope of a program; they cannot be easily predicted and can generally only be caught as the program executes.
      • std::overflow_error thrown to indicate arithmetic overflow.
      • std::range_error thrown to indicate range errors in internal computation.
      • std::underflow_error thrown to indicate arithmetic underflow.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment