aboutsummaryrefslogtreecommitdiffstats
path: root/dotfiles/exceptions.py
blob: cb6021c0c13f4ea30a72e8c47d7aa5b3a2226715 (plain) (blame)
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
61
62
63
class DotfileException(Exception):
    """An exception the CLI can handle and show to the user."""
    def __init__(self, path, message='an unknown error occurred'):
        self.message = '\'%s\' %s' % (path, message)
        Exception.__init__(self, self.message)

    def __str__(self):
        return 'ERROR: %s' % self.message


class IsDirectory(DotfileException):
    def __init__(self, path):
        DotfileException.__init__(self, path, 'is a directory')


class IsSymlink(DotfileException):
    def __init__(self, path):
        DotfileException.__init__(self, path, 'is a symlink')


class NotASymlink(DotfileException):
    def __init__(self, path):
        DotfileException.__init__(self, path, 'is not a symlink')


class InRepository(DotfileException):
    def __init__(self, path):
        DotfileException.__init__(self, path, 'is within the repository')


class NotRootedInHome(DotfileException):
    def __init__(self, path):
        DotfileException.__init__(self, path, 'not rooted in home directory')


class Exists(DotfileException):
    def __init__(self, path):
        DotfileException.__init__(self, path, 'already exists')


class NotFound(DotfileException):
    def __init__(self, path):
        DotfileException.__init__(self, path, 'not found')


class Dangling(DotfileException):
    def __init__(self, path):
        DotfileException.__init__(self, path, 'is a dangling symlink')


class TargetIgnored(DotfileException):
    def __init__(self, path):
        DotfileException.__init__(self, path, 'targets an ignored file')


class TargetExists(DotfileException):
    def __init__(self, path):
        DotfileException.__init__(self, path, 'target already exists')


class TargetMissing(DotfileException):
    def __init__(self, path):
        DotfileException.__init__(self, path, 'target is missing')