summaryrefslogtreecommitdiff
path: root/src/leap/eip/exceptions.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/eip/exceptions.py')
-rw-r--r--src/leap/eip/exceptions.py115
1 files changed, 85 insertions, 30 deletions
diff --git a/src/leap/eip/exceptions.py b/src/leap/eip/exceptions.py
index 19a0e707..3c8f6afb 100644
--- a/src/leap/eip/exceptions.py
+++ b/src/leap/eip/exceptions.py
@@ -1,71 +1,126 @@
-class EIPNoCommandError(Exception):
- pass
+"""
+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).
-class ConnectionError(Exception):
- """
- generic connection error
- """
- pass
+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
"""
- def __str__(self):
- if len(self.args) >= 1:
- return repr(self.args[0])
- else:
- return ConnectionError
+ critical = False
-class UnrecoverableError(EIPClientError):
+class CriticalError(EIPClientError):
"""
we cannot do anything about it, sorry
"""
- # XXX we should catch this and raise
- # to qtland, so we emit signal
- # to translate whatever kind of error
- # to user-friendly msg in dialog.
- pass
+ critical = True
+ failfirst = True
-class MissingSocketError(Exception):
+class Warning(EIPClientError):
+ """
+ just that, warnings
+ """
pass
-class ConnectionRefusedError(Exception):
- pass
+class EIPNoPolkitAuthAgentAvailable(CriticalError):
+ message = "No polkit authentication agent could be found"
+ usermessage = ("We could not find any authentication "
+ "agent in your system.<br/>"
+ "Make sure you have "
+ "<b>polkit-gnome-authentication-agent-1</b> "
+ "running and try again.")
-class EIPNoPkexecAvailable(Exception):
- pass
+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 EIPNoCommandError(EIPClientError):
+ message = "no suitable openvpn command found"
+ usermessage = ("No suitable openvpn command found. "
+ "<br/>(Might be a permissions problem)")
+
+#
+# errors still needing some love
+#
-class EIPNoPolkitAuthAgentAvailable(Exception):
+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 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 EIPInitNoProviderError(Exception):
+class EIPInitNoProviderError(EIPClientError):
pass
-class EIPInitBadProviderError(Exception):
+class EIPInitBadProviderError(EIPClientError):
pass
-class EIPInitNoKeyFileError(Exception):
+class EIPConfigurationError(EIPClientError):
pass
+#
+# Errors that probably we don't need anymore
+# chase down for them and check.
+#
-class EIPInitBadKeyFilePermError(Exception):
+
+class MissingSocketError(Exception):
pass
-class EIPMissingDefaultProvider(Exception):
+class ConnectionRefusedError(Exception):
pass
-class EIPConfigurationError(Exception):
+class EIPMissingDefaultProvider(Exception):
pass