aboutsummaryrefslogtreecommitdiffstats
path: root/tagit/utils/errors.py
blob: 8b5e21af0644bdaae0fad821284284655c40ac60 (plain)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"""Module-wide errors.

Part of the tagit module.
A copy of the license is provided with the project.
Author: Matthias Baumgartner, 2022
"""
# exports
__all__ = (
    'EmptyFileError',
    'LoaderError',
    'NotAFileError',
    'ProgrammingError',
    'UserError',
    'abstract',
    )


## code ##

def abstract():
    """Marks that a method has to be implemented in a child class."""
    raise NotImplementedError('abstract method that must be implemented in a subclass')

class ProgrammingError(Exception):
    """Reached a program state that shouldn't be reachable."""
    pass

class UserError(ValueError):
    """Found an illegal value that was specified directly by the user."""
    pass

class NotAFileError(OSError):
    """A file-system object is not a regular file."""
    pass

class EmptyFileError(OSError):
    """A file is unexpectedly empty."""
    pass

class LoaderError(Exception):
    """Failed to load or initialize a critical data structure."""
    pass

class ParserFrontendError(Exception):
    """Generic parser frontend error."""
    pass

class ParserBackendError(Exception):
    """Generic parser backend error."""
    pass

class ParserError(Exception):
    """String parsing failure."""
    pass

class BackendError(Exception):
    """Generic backend error."""
    pass

## EOF ##