campy.system.error module¶
Top-level Exceptions and Errors.
Provides a generic function to raise an error from a message.
All exceptions (that are not builtin exceptions like ValueError, IndexError)
raised in this library inherit from CampyException, the root of all
exceptions in this library.
-
exception
campy.system.error.CampyException[source]¶ Bases:
ExceptionRoot of all exceptions in the
campymodule.This allows for consistent exception reporting in the module.
-
exception
campy.system.error.InterruptedIOError[source]¶ Bases:
campy.system.error.CampyExceptionA blocking I/O call is interrupted by closing the program.
-
campy.system.error.error(message)[source]¶ Generic function to raise an error.
Signals an error condition in a program by throwing an
CampyException: with the specified message.Parameters: message (str) – error message Raises: An CampyExceptionwith the supplied error message.Usage:
if 'Red Leicester' not in cheeses: error("I'm afraid we're fresh out of Red Leicester, sir.")
You can check whether a code block raises a
CampyExceptionwith:try: do_something_that_might_raise_a_campy_exception() except CampyException: recover_from_an_error()
If the supplied message is an instance or a subclass of
Exception, theCampyExceptionis raised from the supplied Exception so that traceback information is maintained.