summaryrefslogtreecommitdiff
path: root/src/leap/eip
diff options
context:
space:
mode:
authorkali <kali@leap.se>2012-09-06 02:27:04 +0900
committerkali <kali@leap.se>2012-09-06 02:27:04 +0900
commit8148bc9c8c113c41fcb18b397669b1f13447c653 (patch)
tree226ed4f238369f8937c28e3d0f11258cbfb7b506 /src/leap/eip
parentc190b7f66cc1977d0e058bfa2d8fc1a850326320 (diff)
more generic error handler in EipConductorAppMixin
documentation of the Exception Hierarchy and attributes. also a bit of general cleanup around error handling in conductor. Hopefully to be polished an abstracted to leap.base with time. not all errors are converted (and the old with_errors/ignoring errors) are still there, but we should be using this style of handlers from now on. wrapping up with this pseudo-feature for now. as we work on individual features we can mimick the exceptions that are working.
Diffstat (limited to 'src/leap/eip')
-rw-r--r--src/leap/eip/eipconnection.py4
-rw-r--r--src/leap/eip/exceptions.py97
2 files changed, 77 insertions, 24 deletions
diff --git a/src/leap/eip/eipconnection.py b/src/leap/eip/eipconnection.py
index e090f9a7..5c54a986 100644
--- a/src/leap/eip/eipconnection.py
+++ b/src/leap/eip/eipconnection.py
@@ -24,7 +24,6 @@ class EIPConnection(OpenVPNConnection):
self.settingsfile = kwargs.get('settingsfile', None)
self.logfile = kwargs.get('logfile', None)
- # XXX USE THIS
self.error_queue = Queue.Queue()
status_signals = kwargs.pop('status_signals', None)
@@ -33,6 +32,9 @@ class EIPConnection(OpenVPNConnection):
super(EIPConnection, self).__init__(*args, **kwargs)
+ def has_errors(self):
+ return True if self.error_queue.qsize != 0 else True
+
def run_checks(self, skip_download=False):
"""
run all eip checks previous to attempting a connection
diff --git a/src/leap/eip/exceptions.py b/src/leap/eip/exceptions.py
index a30cd2a6..3c8f6afb 100644
--- a/src/leap/eip/exceptions.py
+++ b/src/leap/eip/exceptions.py
@@ -1,23 +1,60 @@
+"""
+Generic error hierarchy
+Leap/EIP exceptions used for exception handling,
+logging, and notifying user of errors
+during leap operation.
+
+Exception hierarchy
+-------------------
+All EIP Errors must inherit from EIPClientError (note: move that to
+a more generic LEAPClientBaseError).
+
+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.
+
+TODO:
+
+* EIPClientError:
+ Should inherit from LeapException
+ and move basic attrs there
+
+* gettext / i18n for user messages.
+
+"""
+
+
class EIPClientError(Exception):
"""
base EIPClient exception
"""
- # Should inherit from LeapException
- # and move basic attrs there
critical = False
- #def __str__(self):
- #if len(self.args) >= 1:
- #return repr(self.args[0])
- #else:
- #return ConnectionError
-
class CriticalError(EIPClientError):
"""
we cannot do anything about it, sorry
"""
critical = True
+ failfirst = True
+
+
+class Warning(EIPClientError):
+ """
+ just that, warnings
+ """
+ pass
class EIPNoPolkitAuthAgentAvailable(CriticalError):
@@ -28,33 +65,53 @@ class EIPNoPolkitAuthAgentAvailable(CriticalError):
"<b>polkit-gnome-authentication-agent-1</b> "
"running and try again.")
-# Errors needing some work
+class EIPNoPkexecAvailable(Warning):
+ message = "No pkexec binary found"
+ usermessage = ("We could not find <b>pkexec</b> in your "
+ "system.<br/> Do you want to try "
+ "<b>setuid workaround</b>? "
+ "(<i>DOES NOTHING YET</i>)")
+ failfirst = True
-class EIPNoPkexecAvailable(Exception):
- pass
+class EIPNoCommandError(EIPClientError):
+ message = "no suitable openvpn command found"
+ usermessage = ("No suitable openvpn command found. "
+ "<br/>(Might be a permissions problem)")
-class EIPInitNoProviderError(Exception):
- pass
+#
+# errors still needing some love
+#
+
+class EIPInitNoKeyFileError(CriticalError):
+ message = "No vpn keys found in the expected path"
+ usermessage = "We could not find your eip certs in the expected path"
-class EIPInitBadProviderError(Exception):
+
+class EIPInitBadKeyFilePermError(Warning):
+ # I don't know if we should be telling user or not,
+ # we try to fix permissions and should only re-raise
+ # if permission check failed.
pass
-class EIPInitNoKeyFileError(Exception):
+class EIPInitNoProviderError(EIPClientError):
pass
-class EIPInitBadKeyFilePermError(Exception):
+class EIPInitBadProviderError(EIPClientError):
pass
-class EIPNoCommandError(Exception):
+class EIPConfigurationError(EIPClientError):
pass
+#
# Errors that probably we don't need anymore
+# chase down for them and check.
+#
class MissingSocketError(Exception):
@@ -65,11 +122,5 @@ class ConnectionRefusedError(Exception):
pass
-
-
class EIPMissingDefaultProvider(Exception):
pass
-
-
-class EIPConfigurationError(Exception):
- pass