File: _exceptions.py

package info (click to toggle)
python-asv-runner 0.2.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 420 kB
  • sloc: python: 1,631; makefile: 13
file content (35 lines) | stat: -rw-r--r-- 1,095 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
class NotRequired(ImportError):
    """
    Exception raised when a requirement is not met.

    This exception inherits from `ImportError`. It's typically used when a particular
    package, module or other dependency that is not essential for the overall function
    of the program is not found or doesn't meet specific requirements.

    #### Attributes
    **message** (`str`)
    : A string that provides a more detailed explanation of the error.

    #### Example
    This exception might be used in a scenario where an optional feature of a program
    relies on a specific package that is not installed:


    ```{code-block} python
    try:
        import optional_package
    except ImportError:
        raise NotRequired("optional_package is not installed.")
    ```
    """

    def __init__(self, message):
        """
        Initialize a new instance of `NotRequired`.

        #### Parameters
        **message** (`str`)
        : A string that provides a more detailed explanation of the error.
        """
        self.message = message
        super().__init__(self.message)