# environment error (e.g. node disk error)
ECODE_ENVIRON = "environment_error"
+#: List of all failure types
+ECODE_ALL = frozenset([
+ ECODE_RESOLVER,
+ ECODE_NORES,
+ ECODE_INVAL,
+ ECODE_STATE,
+ ECODE_NOENT,
+ ECODE_EXISTS,
+ ECODE_NOTUNIQUE,
+ ECODE_FAULT,
+ ECODE_ENVIRON,
+ ])
+
class GenericError(Exception):
"""Base exception for Ganeti.
pass
+class PidFileLockError(LockError):
+ """PID file is already locked by another process.
+
+ """
+
+
class HypervisorError(GenericError):
"""Hypervisor-related exception.
"""
+class OpResultError(GenericError):
+ """Issue with OpCode result.
+
+ """
+
+
class OpCodeUnknown(GenericError):
"""Unknown opcode submitted.
"""
+class X509CertError(GenericError):
+ """Invalid X509 certificate.
+
+ This error has two arguments: the certificate filename and the error cause.
+
+ """
+
+
class TagError(GenericError):
"""Generic tag error.
"""
+class QueryFilterParseError(ParseError):
+ """Error while parsing query filter.
+
+ """
+ def GetDetails(self):
+ """Returns a list of strings with details about the error.
+
+ """
+ try:
+ (_, inner) = self.args
+ except IndexError:
+ return None
+
+ return [str(inner.line),
+ (" " * (inner.column - 1)) + "^",
+ str(inner)]
+
+
# errors should be added above
error = GetEncodedError(result)
if error:
(errcls, args) = error
- raise errcls, args
+ raise errcls(args)