<jupyter_start><jupyter_text>In python all exceptions must be instances of a class that derives from BaseException. In a try statement with an except clause that mentions a particular class, that clause also handles any exception classes derived from that class (but not exception classes from which it is derived). Two exception classes that are not related via subclassing are never equivalent, even if they have the dame name.The built-in exceptions listed below can be generated by the interpreter or built-in functions. Except where mentioned they have an associated value indication the detailed cause of the error. This may be a string or a tuple of several items of information (e.g., an error code and a string explaining the code). The associated value is usually passed as arguments to the exception class's constructor<jupyter_code>raise 'new_exc' from 'original_exc'<jupyter_output><empty_output><jupyter_text>*exception* **BaseException*** **exception Exception** - All built in* **exception ArithmeticError** - For variour arithmetic errors* **exception BufferError** - For when buffer related operation cannot be performed Concrete exceptions* **exception AssertionError** - Raised when an assert statement fails* **exception AttributeError** - Raised when an attribute ref or assignment fails. * **exception EOFError** - Raised when the input() function hits an end-of-file condition (EOF).* **exception FloatingPointError** - Not currently used.* **exception GeneratorExit** - Raised whem a gemerator or coroutine is closed.* **exception ImportError** - Raised when the import statement has trouble trying to load a module.* **exception ModuleNotFoundError** - A subclass of ImportError which is reaised by import when a module could not be located.* **exception IndexError** - Raised when a seq subscript is out of range.* **exception Keyerror** - Raised when a mapping (dictionary) key is not found in the set of existing keys.* **exception KeyboardInterrupt** - Raised when the iser hits the interrupt key (normally control-C or Delete)* **exception MemoryError** - Raised when an operation runs out of memory but the situation may still be rescued (by deleting some objects).* **exception NameError** - Raised when a local or global name is not found. This applies only to unqualified names. THe associated value is an error message that includes the name could not be found. * **exception NotImplementedError** - This exception is derived from RuntimeError. In user defined base classes, abstract methods should raise this exception when they require derived classes to override the method, or while the class is being developed to indicate that the real implementation still needs to be added.* **exception OSError** - This exception is raised when a system function returns a system-related error, including I/O failures such as "file not found" or "disk full" (not for illegal argument types or other incidental errors).* **exception OverflowError** - Raised when the result of an arithmetic operation is too large to be represented. This cannot occur for integers (which would rather raise MemoryError that give up).* **exception RecursionError** - This exception is derived from RuntimeError. It is raised when the interpreter detects that the mazimum recursion depth is exceeded.* **exception ReferenceError** - This exception is raised when a weak reference proxy, created by the weakref.proxy() function, is used to access an attribute of the referent after it has been garbage collected.* **exception RuntimeError** - Raised when an error is detected that does not fall in any of the other categories. The associated value is a string indicating what precisely went wrong.* **exception StopIteration** - Raised by built-in function next() and an iterator;s `__next__` method to signal that there are no firther items prodiced by the iterator* **exception StopAsyncIteration** - Must be raised by `__anext__()` method od an asynchronous iterator object to stop the iteration.* **exception SyntaxError** - Raised when the parsed encounters a syntax error. This may occur in an import statement, in a call to the built-in functions exec() or eval(), or when reading the initial script or standarrd input (also interactively)* **exception IndentationError** - Base class for syntax errors related to incorrect indentation. This is a subclass of `SyntaxError`.* **exception TabError** - Raised when indentation containes an incosistent use of tabs and soaces. This is a subclass of `IndentationError`.* **exception SystemError** - Raised when the interpreter finds an internam error, but the situation does not look so serious to cause it to abondon all hope. The associated value is a string indication what went wrong (in low-level terms)* **exception SystemExit** - This exception is raised by the sys.exit() function. It inherits from `BaseException` instead of `Exception` so that it is not accidentally caught bu code that catches `Exception`.* **exception TypeError** - Raised when an operation or function is applied to an object of inappropriate type. The associated value is a string giving details about the type mismatch.* **exception  UnboundLocalError** - Raised when a reference is made to a local variable in a function or method, but no value has been bound to that variable. This is a subclass of NameError.* **exception UnicodeError** - Raised when a Unicode-related encoding or decoding error occurs. It is a subclass of `ValueError`.* **exception UnicodeEncodeError** - Raised when a Unicode-related error occurs during encoding. It is a subclass of `UnicodeError`.* **exception UnicodeDecodeError** - Raised when a Unicode-related error occurs during encoding. It is a subclass of `UnicodeError`.* **exception UnicodeTranslateError** - Raised when a Unicode-related error occurs during translating. It is a subclass of `UnicodeError`.* **exception ValueError** - Raised when an operation or function receives an argument that has the right type but an inappropriate value, and the situation is not described by a more precise exception such as `IndexError`.* **exception ZeroDivisionError** - Raised when the secind argument of a division or modulo operation is zero. This associated value is a string indication the type of the operands and the operation.* **exception EnvironmentError*** **exception IOError*** **exception WindowsError** - Only available on Windows OS exceptions* **exception BlockingIOError** - Raised when an operation would block on an object (e.g. socket) set for non-blocking operation. Corresponds to `errno` `EAGAIN`, `EALREADY`, `EWOULDBLOCK` and `EINPROGRESS`.* **exception ChildProcessError** - Raised when an operation on a child process failed. Corresponds to errno `ECHILD`.* **exception ConnectionError** - A base class for connection-related issues. Subclasses are `BrokenPipeError`, `ConnectionAbortedError`, `ConnectionRefusedError` and `ConnectionResetError`.* **exception BrokenPipeError** - A subclass of ConnectionError, raised when trying to write on a pipe while the other end has been closed, or trying to write on a socket which has been shutdown for writing. Corresponds to errno `EPIPE` and `ESHUTDOWN`.* **exception ConnectionAbortedError** - A subclass of ConnectionError, raised when a connection attempt is aborted by the peer. Corresponds to errno `ECONNABORTED`.* **exception ConnectionRefusedError** - A subclass of ConnectionError, raised when a connection attempt is refused by the peer. Corresponds to errno `ECONNREFUSED`.* **exception ConnectionResetError** - A subclass of ConnectionError, raised when a connection is reset by the peer. Corresponds to errno `ECONNRESET`.* **exception FileExistsError** - Raised when trying to create a file or directory which already exists. Corresponds to errno `EEXIST`.* **exception FileNotFoundError** - Raised when a file or directory is requested but doesn’t exist. Corresponds to errno `ENOENT`. * **exception InterruptedError** - Raised when a system call is interrupted by an incoming signal. Corresponds to errno `EINTR`.* **exception IsADirectoryError** - Raised when a file operation (such as os.remove()) is requested on a directory. Corresponds to errno `EISDIR`.* **exception NotADirectoryError** - Raised when a directory operation (such as os.listdir()) is requested on something which is not a directory. Corresponds to errno `ENOTDIR`.* **exception PermissionError** - Raised when trying to run an operation without the adequate access rights - for example filesystem permissions. Corresponds to errno `EACCES` and `EPERM`.* **exception ProcessLookupError** - Raised when a given process doesn’t exist. Corresponds to errno `ESRCH`.* **exception TimeoutError** - Raised when a system function timed out at the system level. Corresponds to errno `ETIMEDOUT`. Warnings* **exception Warning** - Base class for warning categories.* **exception UserWarning** - Base class for warnings generated by user code.* **exception DeprecationWarning** - Base class for warnings about deprecated features when those warnings are intended for other Python developers.* **exception PendingDeprecationWarning** - Base class for warnings about features which are obsolete and expected to be deprecated in the future, but are not deprecated at the moment.* **exception SyntaxWarning** - Base class for warnings about dubious syntax.* **exception RuntimeWarning** - Base class for warnings about dubious runtime behavior.* **exception FutureWarning** - Base class for warnings about deprecated features when those warnings are intended for end users of applications that are written in Python.* **exception ImportWarning** - Base class for warnings about probable mistakes in module imports.* **exception UnicodeWarning** - Base class for warnings related to Unicode. * **exception BytesWarning** - Base class for warnings related to bytes and bytearray.* **exception ResourceWarning** - Base class for warnings related to resource usage. Custom Exception<jupyter_code>class JustAnExampleError(Exception):
    pass
a = 2
if a == 2:
    raise JustAnExampleError('It is just for an example')<jupyter_output><empty_output><jupyter_text>Exception hierarchy<jupyter_code>BaseException
 +-- SystemExit
 +-- KeyboardInterrupt
 +-- GeneratorExit
 +-- Exception
      +-- StopIteration
      +-- StopAsyncIteration
      +-- ArithmeticError
      |    +-- FloatingPointError
      |    +-- OverflowError
      |    +-- ZeroDivisionError
      +-- AssertionError
      +-- AttributeError
      +-- BufferError
      +-- EOFError
      +-- ImportError
      |    +-- ModuleNotFoundError
      +-- LookupError
      |    +-- IndexError
      |    +-- KeyError
      +-- MemoryError
      +-- NameError
      |    +-- UnboundLocalError
      +-- OSError
      |    +-- BlockingIOError
      |    +-- ChildProcessError
      |    +-- ConnectionError
      |    |    +-- BrokenPipeError
      |    |    +-- ConnectionAbortedError
      |    |    +-- ConnectionRefusedError
      |    |    +-- ConnectionResetError
      |    +-- FileExistsError
      |    +-- FileNotFoundError
      |    +-- InterruptedError
      |    +-- IsADirectoryError
      |    +-- NotADirectoryError
      |    +-- PermissionError
      |    +-- ProcessLookupError
      |    +-- TimeoutError
      +-- ReferenceError
      +-- RuntimeError
      |    +-- NotImplementedError
      |    +-- RecursionError
      +-- SyntaxError
      |    +-- IndentationError
      |         +-- TabError
      +-- SystemError
      +-- TypeError
      +-- ValueError
      |    +-- UnicodeError
      |         +-- UnicodeDecodeError
      |         +-- UnicodeEncodeError
      |         +-- UnicodeTranslateError
      +-- Warning
           +-- DeprecationWarning
           +-- PendingDeprecationWarning
           +-- RuntimeWarning
           +-- SyntaxWarning
           +-- UserWarning
           +-- FutureWarning
           +-- ImportWarning
           +-- UnicodeWarning
           +-- BytesWarning
           +-- ResourceWarning<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07655303972795886, 'fraction_numerical': 0.0001658787426391308, 'mean_word_length': 3.929681112019624, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '609963', 'license': 'Apache-2.0', 'n_tokens_mistral': 2913, 'n_tokens_neox': 2766, 'n_words': 1435, 'path': '4 - Built-in Exceptions.ipynb', 'repo_name': 'shubhamnag14/Python-Documents', 'size': '12057'}