qubes.exc
– Exceptions¶
As most of the modern programming languages, Python has exceptions, which can be
thrown (raise
d) when something goes bad. What exactly means “bad” depends
on several circumstances.
One of those circumstances is who exactly is to blame: programmer or user? Some errors are commited by programmer and will most probably result it program failure. But most errors are caused by the user, notably by specifying invalid commands or data input. Those errors should not result in failure, but fault and be handled gracefuly. One more time, what “gracefuly” means depends on specific program and its interface (for example GUI programs should most likely display some admonition, but will not crash).
In Qubes we have special exception class, qubes.exc.QubesException
,
which is dedicated to handling user-caused problems. Programmer errors should
not result in raising QubesException, but it should instead result in one of the
standard Python exception. QubesExceptions should have a nice message that can
be shown to the user. On the other hand, some children classes of QubesException
also inherit from children of StandardException
to allow uniform
except
clauses.
Often the error relates to some domain, because we expect it to be in certain
state, but it is not. For example to start a machine, it should be halted. For
that we have the children of the qubes.exc.QubesVMError
class. They
all take the domain in question as their first argument and an (optional)
message as the second. If not specified, there is stock message which is
generally informative enough.
On writing error messages¶
As a general rule, error messages should be short but precise. They should not blame user for error, but the user should know, what had been done wrong and what to do next.
If possible, write the message that is stating the fact, for example “Domain is not running” instead of “You forgot to start the domain” (you fool!). Avoid commanding user, like “Start the domain first” (user is not a function you can call for effect). Instead consider writing in negative form, implying expected state: “Domain is not running” instead of “Domain is paused” (yeah, what’s wrong with that?).
Also avoid implying the personhood of the computer, including adressing user in second person. For example, write “Sending message failed” instead of “I failed to send the message”.
Inheritance diagram¶
digraph inheritanceddb8932c08 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "qubes.exc.BackupAlreadyRunningError" [URL="#qubes.exc.BackupAlreadyRunningError",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Thrown at user when they try to run the same backup twice at"]; "qubes.exc.QubesException" -> "qubes.exc.BackupAlreadyRunningError" [arrowsize=0.5,style="setlinewidth(0.5)"]; "qubes.exc.BackupCancelledError" [URL="#qubes.exc.BackupCancelledError",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Thrown at user when backup was manually cancelled"]; "qubes.exc.QubesException" -> "qubes.exc.BackupCancelledError" [arrowsize=0.5,style="setlinewidth(0.5)"]; "qubes.exc.PermissionDenied" [URL="#qubes.exc.PermissionDenied",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Raised deliberately by handlers when we decide not to cooperate"]; "qubes.exc.ProtocolError" [URL="#qubes.exc.ProtocolError",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Raised when something is wrong with data received"]; "qubes.exc.QubesException" [URL="#qubes.exc.QubesException",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Exception that can be shown to the user"]; "qubes.exc.QubesFeatureNotFoundError" [URL="#qubes.exc.QubesFeatureNotFoundError",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Feature not set for a given domain"]; "qubes.exc.QubesException" -> "qubes.exc.QubesFeatureNotFoundError" [arrowsize=0.5,style="setlinewidth(0.5)"]; "qubes.exc.QubesLabelNotFoundError" [URL="#qubes.exc.QubesLabelNotFoundError",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Label does not exists"]; "qubes.exc.QubesException" -> "qubes.exc.QubesLabelNotFoundError" [arrowsize=0.5,style="setlinewidth(0.5)"]; "qubes.exc.QubesMemoryError" [URL="#qubes.exc.QubesMemoryError",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Cannot start domain, because not enough memory is available"]; "qubes.exc.QubesVMError" -> "qubes.exc.QubesMemoryError" [arrowsize=0.5,style="setlinewidth(0.5)"]; "qubes.exc.QubesNoSuchPropertyError" [URL="#qubes.exc.QubesNoSuchPropertyError",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Requested property does not exist"]; "qubes.exc.QubesException" -> "qubes.exc.QubesNoSuchPropertyError" [arrowsize=0.5,style="setlinewidth(0.5)"]; "qubes.exc.QubesNoTemplateError" [URL="#qubes.exc.QubesNoTemplateError",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Cannot start domain, because there is no template"]; "qubes.exc.QubesVMError" -> "qubes.exc.QubesNoTemplateError" [arrowsize=0.5,style="setlinewidth(0.5)"]; "qubes.exc.QubesNotImplementedError" [URL="#qubes.exc.QubesNotImplementedError",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Thrown at user when some feature is not implemented"]; "qubes.exc.QubesException" -> "qubes.exc.QubesNotImplementedError" [arrowsize=0.5,style="setlinewidth(0.5)"]; "qubes.exc.QubesPoolInUseError" [URL="#qubes.exc.QubesPoolInUseError",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="VM is in use, cannot remove."]; "qubes.exc.QubesException" -> "qubes.exc.QubesPoolInUseError" [arrowsize=0.5,style="setlinewidth(0.5)"]; "qubes.exc.QubesPropertyValueError" [URL="#qubes.exc.QubesPropertyValueError",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Cannot set value of qubes.property, because user-supplied value is wrong."]; "qubes.exc.QubesValueError" -> "qubes.exc.QubesPropertyValueError" [arrowsize=0.5,style="setlinewidth(0.5)"]; "qubes.exc.QubesTagNotFoundError" [URL="#qubes.exc.QubesTagNotFoundError",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Tag not set for a given domain"]; "qubes.exc.QubesException" -> "qubes.exc.QubesTagNotFoundError" [arrowsize=0.5,style="setlinewidth(0.5)"]; "qubes.exc.QubesVMError" [URL="#qubes.exc.QubesVMError",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Some problem with domain state."]; "qubes.exc.QubesException" -> "qubes.exc.QubesVMError" [arrowsize=0.5,style="setlinewidth(0.5)"]; "qubes.exc.QubesVMInUseError" [URL="#qubes.exc.QubesVMInUseError",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="VM is in use, cannot remove."]; "qubes.exc.QubesVMError" -> "qubes.exc.QubesVMInUseError" [arrowsize=0.5,style="setlinewidth(0.5)"]; "qubes.exc.QubesVMInvalidUUIDError" [URL="#qubes.exc.QubesVMInvalidUUIDError",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Domain UUID is invalid"]; "qubes.exc.QubesException" -> "qubes.exc.QubesVMInvalidUUIDError" [arrowsize=0.5,style="setlinewidth(0.5)"]; "qubes.exc.QubesVMNotFoundError" [URL="#qubes.exc.QubesVMNotFoundError",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Domain cannot be found in the system"]; "qubes.exc.QubesException" -> "qubes.exc.QubesVMNotFoundError" [arrowsize=0.5,style="setlinewidth(0.5)"]; "qubes.exc.QubesVMNotHaltedError" [URL="#qubes.exc.QubesVMNotHaltedError",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Domain is not halted."]; "qubes.exc.QubesVMError" -> "qubes.exc.QubesVMNotHaltedError" [arrowsize=0.5,style="setlinewidth(0.5)"]; "qubes.exc.QubesVMNotPausedError" [URL="#qubes.exc.QubesVMNotPausedError",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Domain is not paused."]; "qubes.exc.QubesVMNotStartedError" -> "qubes.exc.QubesVMNotPausedError" [arrowsize=0.5,style="setlinewidth(0.5)"]; "qubes.exc.QubesVMNotRunningError" [URL="#qubes.exc.QubesVMNotRunningError",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Domain is not running."]; "qubes.exc.QubesVMNotStartedError" -> "qubes.exc.QubesVMNotRunningError" [arrowsize=0.5,style="setlinewidth(0.5)"]; "qubes.exc.QubesVMNotStartedError" [URL="#qubes.exc.QubesVMNotStartedError",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Domain is not started."]; "qubes.exc.QubesVMError" -> "qubes.exc.QubesVMNotStartedError" [arrowsize=0.5,style="setlinewidth(0.5)"]; "qubes.exc.QubesVMNotSuspendedError" [URL="#qubes.exc.QubesVMNotSuspendedError",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Domain is not suspended."]; "qubes.exc.QubesVMError" -> "qubes.exc.QubesVMNotSuspendedError" [arrowsize=0.5,style="setlinewidth(0.5)"]; "qubes.exc.QubesVMShutdownTimeoutError" [URL="#qubes.exc.QubesVMShutdownTimeoutError",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Domain shutdown timed out."]; "qubes.exc.QubesVMError" -> "qubes.exc.QubesVMShutdownTimeoutError" [arrowsize=0.5,style="setlinewidth(0.5)"]; "qubes.exc.QubesValueError" [URL="#qubes.exc.QubesValueError",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Cannot set some value, because it is invalid, out of bounds, etc."]; "qubes.exc.QubesException" -> "qubes.exc.QubesValueError" [arrowsize=0.5,style="setlinewidth(0.5)"]; }Module contents¶
Qubes OS exception hierarchy
- exception qubes.exc.BackupAlreadyRunningError(msg=None)[source]¶
Bases:
QubesException
Thrown at user when they try to run the same backup twice at the same time
- exception qubes.exc.BackupCancelledError(msg=None)[source]¶
Bases:
QubesException
Thrown at user when backup was manually cancelled
- exception qubes.exc.PermissionDenied[source]¶
Bases:
Exception
Raised deliberately by handlers when we decide not to cooperate
- exception qubes.exc.ProtocolError[source]¶
Bases:
AssertionError
Raised when something is wrong with data received
- exception qubes.exc.QubesException[source]¶
Bases:
Exception
Exception that can be shown to the user
- exception qubes.exc.QubesFeatureNotFoundError(domain, feature)[source]¶
Bases:
QubesException
,KeyError
Feature not set for a given domain
- exception qubes.exc.QubesLabelNotFoundError(label)[source]¶
Bases:
QubesException
,KeyError
Label does not exists
- exception qubes.exc.QubesMemoryError(vm, msg=None)[source]¶
Bases:
QubesVMError
,MemoryError
Cannot start domain, because not enough memory is available
- exception qubes.exc.QubesNoSuchPropertyError(holder, prop_name, msg=None)[source]¶
Bases:
QubesException
,AttributeError
Requested property does not exist
- exception qubes.exc.QubesNoTemplateError(vm, msg=None)[source]¶
Bases:
QubesVMError
Cannot start domain, because there is no template
- exception qubes.exc.QubesNotImplementedError(msg=None)[source]¶
Bases:
QubesException
,NotImplementedError
Thrown at user when some feature is not implemented
- exception qubes.exc.QubesPoolInUseError(pool, msg=None)[source]¶
Bases:
QubesException
VM is in use, cannot remove.
- exception qubes.exc.QubesPropertyValueError(holder, prop, value, msg=None)[source]¶
Bases:
QubesValueError
Cannot set value of qubes.property, because user-supplied value is wrong.
- exception qubes.exc.QubesTagNotFoundError(domain, tag)[source]¶
Bases:
QubesException
,KeyError
Tag not set for a given domain
- exception qubes.exc.QubesVMError(vm, msg)[source]¶
Bases:
QubesException
Some problem with domain state.
- exception qubes.exc.QubesVMInUseError(vm, msg=None)[source]¶
Bases:
QubesVMError
VM is in use, cannot remove.
- exception qubes.exc.QubesVMInvalidUUIDError(uuid: str)[source]¶
Bases:
QubesException
Domain UUID is invalid
- exception qubes.exc.QubesVMNotFoundError(vmname)[source]¶
Bases:
QubesException
,KeyError
Domain cannot be found in the system
- exception qubes.exc.QubesVMNotHaltedError(vm, msg=None)[source]¶
Bases:
QubesVMError
Domain is not halted.
This exception is thrown when machine should be halted, but is not (either running or paused).
- exception qubes.exc.QubesVMNotPausedError(vm, msg=None)[source]¶
Bases:
QubesVMNotStartedError
Domain is not paused.
This exception is thrown when machine should be paused, but is not.
- exception qubes.exc.QubesVMNotRunningError(vm, msg=None)[source]¶
Bases:
QubesVMNotStartedError
Domain is not running.
This exception is thrown when machine should be running but is either halted or paused.
- exception qubes.exc.QubesVMNotStartedError(vm, msg=None)[source]¶
Bases:
QubesVMError
Domain is not started.
This exception is thrown when machine is halted, but should be started (that is, either running or paused).
- exception qubes.exc.QubesVMNotSuspendedError(vm, msg=None)[source]¶
Bases:
QubesVMError
Domain is not suspended.
This exception is thrown when machine should be suspended but is either halted or running.
- exception qubes.exc.QubesVMShutdownTimeoutError(vm, msg=None)[source]¶
Bases:
QubesVMError
Domain shutdown timed out.
- exception qubes.exc.QubesValueError[source]¶
Bases:
QubesException
,ValueError
Cannot set some value, because it is invalid, out of bounds, etc.