summaryrefslogtreecommitdiff
path: root/src/leap/base/exceptions.py
blob: 2e31b33b28253b5e89f72ba59762925174711f27 (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
"""
Exception attributes and their meaning/uses
-------------------------------------------

* critical:    if True, will abort execution prematurely,
               after attempting any cleaning
               action.

* failfirst:   breaks any error_check loop that is examining
               the error queue.

* message:     the message that will be used in the __repr__ of the exception.

* usermessage: the message that will be passed to user in ErrorDialogs
               in Qt-land.
"""
from leap.util.translations import translate


class LeapException(Exception):
    """
    base LeapClient exception
    sets some parameters that we will check
    during error checking routines
    """

    critical = False
    failfirst = False
    warning = False


class CriticalError(LeapException):
    """
    we cannot do anything about it
    """
    critical = True
    failfirst = True


# In use ???
# don't thing so. purge if not...

class MissingConfigFileError(Exception):
    pass


class ImproperlyConfigured(Exception):
    pass


# NOTE: "Errors" (context) has to be a explicit string!


class InterfaceNotFoundError(LeapException):
    # XXX should take iface arg on init maybe?
    message = "interface not found"
    usermessage = translate(
        "Errors",
        "Interface not found")


class NoDefaultInterfaceFoundError(LeapException):
    message = "no default interface found"
    usermessage = translate(
        "Errors",
        "Looks like your computer "
        "is not connected to the internet")


class NoConnectionToGateway(CriticalError):
    message = "no connection to gateway"
    usermessage = translate(
        "Errors",
        "Looks like there are problems "
        "with your internet connection")


class NoInternetConnection(CriticalError):
    message = "No Internet connection found"
    usermessage = translate(
        "Errors",
        "It looks like there is no internet connection.")
    # and now we try to connect to our web to troubleshoot LOL :P


class CannotResolveDomainError(LeapException):
    message = "Cannot resolve domain"
    usermessage = translate(
        "Errors",
        "Domain cannot be found")


class TunnelNotDefaultRouteError(LeapException):
    message = "Tunnel connection dissapeared. VPN down?"
    usermessage = translate(
        "Errors",
        "The Encrypted Connection was lost.")