June 2015
Intermediate to advanced
298 pages
7h 15m
English
The hierarchy of exceptions has a superclass for error-related exceptions, called Exception. All of the exceptions which reflect essentially erroneous conditions are subclasses of the Exception class. The base class for all exceptions is the BaseException class; some non-error-related exceptions are direct subclasses of the BaseException class.
We can summarize the hierarchy like this:
BaseExceptionSystemExitKeyboardInterruptGeneratorExitExceptionThe superclass of all error-related exceptions, Exception, is quite broad. We can use this in a long-running server like this:
def server(): try: while True: try: one_request() except Exception as e: print(e.__class__.__name__, e) except Shutdown_Request: print("Shutting ...Read now
Unlock full access