Skip to content

Exceptions

exceptions

HariDirectoryCreationError

Bases: HariError

Exception raised when a directory cannot be created.

Source code in hari_data/exceptions.py
15
16
17
18
19
20
21
22
23
24
25
26
27
class HariDirectoryCreationError(HariError):
    """Exception raised when a directory cannot be created."""

    def __init__(self, directory: str, tb: str, message: Optional[str] = None):
        self.directory = directory
        self.tb = tb
        if message is None:
            message = 'Failed to create directory'
        full_message = f'{message}: {directory}'
        super().__init__(full_message)

    def __str__(self):
        return f'{self.message}\nTraceback:\n{self.tb}'

HariError

Bases: Exception

Exception base for errors related to Hari.

Source code in hari_data/exceptions.py
 4
 5
 6
 7
 8
 9
10
11
12
class HariError(Exception):
    """Exception base for errors related to Hari."""

    def __init__(self, message: str):
        self.message = message
        super().__init__(message)

    def __str__(self):
        return self.message

HariLoggerNotConfigured

Bases: HariError

Exception raised when the logger is not configured.

Source code in hari_data/exceptions.py
30
31
32
33
34
35
36
37
38
39
class HariLoggerNotConfigured(HariError):
    """Exception raised when the logger is not configured."""

    def __init__(self, message: Optional[str] = None):
        if message is None:
            message = 'Logger has not been configured. Call the .configure() method first.'
        super().__init__(message)

    def __str__(self):
        return self.message