New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create exception hierarchy #1279

Closed
woju opened this Issue Oct 6, 2015 · 4 comments

Comments

Projects
None yet
2 participants
@woju
Member

woju commented Oct 6, 2015

There are two kinds of errors: programmer's errors and user/API errors. Current
QubesException is the second kind. Programming errors should not result in
raising QubesException, but standard python exceptions and end in tool's crash
and possibly log message.

Children of QubesException may also inherit from children of StandardError
(that is, from vanilla python exceptions like KeyError, ValueError etc.), so
we can write readable try/except statements. In this case we should inherit
from QubesException first.

The AssertionError standard exception is tricky, because when this error is
catched by testsuite the test result is FAIL instead of ERROR. Perhaps
QubesVMError can inherit from it.

Proposed hierarchy:

  • QubesException (root; has nice description to display to user)
    • QubesVMNotFoundError (+LookupError or KeyError; vm cannot be found
      when looking up by qid, uuid or name)
    • QubesVMError (+AssertionError?; some problem with machine or its state;
      first param is the domain in question)
      • QubesVMNotRunningError (not active)
      • QubesVMNotStartedError
      • QubesVMNotHaltedError
      • QubesVMNotPausedError
      • QubesVMNotSuspendedError
    • QubesValueError (+ValueError; wrong value while setting property)
    • QubesNotImplementedError (+NotImplementedError)
    • BackupCancelledError
    • QubesMemoryError (+MemoryError; cannot start domain)
    • QubesNoTemplateError (template not found, like after incomplete backup)
    • QubesStoreError (problem with qubes.xml: not found, syntax error, etc.)

@woju woju self-assigned this Oct 6, 2015

@woju woju added this to the Release 4.0 milestone Oct 6, 2015

@woju woju added C: core task labels Oct 6, 2015

@marmarek

This comment has been minimized.

Show comment
Hide comment
@marmarek

marmarek Oct 6, 2015

Member

On Tue, Oct 06, 2015 at 03:53:54AM -0700, Wojtek Porczyk wrote:

  • QubesException (root; has nice description to display to user)
    • QubesVMNotFoundError (+LookupError or KeyError; vm cannot be found
      when looking up by qid, uuid or name)
    • QubesVMError (+AssertionError?; some problem with machine or its state;
      first param is the domain in question)
      • QubesVMNotRunningError (not active)
      • QubesVMNotStartedError

What is the difference?

- `QubesVMNotHaltedError`
- `QubesVMNotPausedError`
- `QubesVMNotSuspendedError`
  • QubesValueError (+ValueError; wrong value while setting property)

QubesPropertyValueError ?

  • QubesNotImplementedError (+NotImplementedError)
  • BackupCancelledError
  • QubesMemoryError (+MemoryError; cannot start domain)
  • QubesNoTemplateError (template not found, like after incomplete backup)

May also cover incompatible template case (for example trying to create
HVM based on PV template). Or should it be QubesPropertyValueError?

  • QubesStoreError (problem with qubes.xml: not found, syntax error, etc.)

Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

Member

marmarek commented Oct 6, 2015

On Tue, Oct 06, 2015 at 03:53:54AM -0700, Wojtek Porczyk wrote:

  • QubesException (root; has nice description to display to user)
    • QubesVMNotFoundError (+LookupError or KeyError; vm cannot be found
      when looking up by qid, uuid or name)
    • QubesVMError (+AssertionError?; some problem with machine or its state;
      first param is the domain in question)
      • QubesVMNotRunningError (not active)
      • QubesVMNotStartedError

What is the difference?

- `QubesVMNotHaltedError`
- `QubesVMNotPausedError`
- `QubesVMNotSuspendedError`
  • QubesValueError (+ValueError; wrong value while setting property)

QubesPropertyValueError ?

  • QubesNotImplementedError (+NotImplementedError)
  • BackupCancelledError
  • QubesMemoryError (+MemoryError; cannot start domain)
  • QubesNoTemplateError (template not found, like after incomplete backup)

May also cover incompatible template case (for example trying to create
HVM based on PV template). Or should it be QubesPropertyValueError?

  • QubesStoreError (problem with qubes.xml: not found, syntax error, etc.)

Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

@woju

This comment has been minimized.

Show comment
Hide comment
@woju

woju Oct 6, 2015

Member

On Tue, Oct 06, 2015 at 04:18:07AM -0700, Marek Marczykowski-Górecki wrote:

- `QubesVMNotRunningError` (not active)
- `QubesVMNotStartedError`

What is the difference?

Paused state. For example .force_shutdown() should work when machine
is started but paused, but .run() requires machine that is running and
not paused. Both should fail when domain is powered off.

Perhaps QubesVMNotRunningError may be a child of
QubesVMNotStartedError.

- `QubesVMNotHaltedError`
- `QubesVMNotPausedError`
- `QubesVMNotSuspendedError`
  • QubesValueError (+ValueError; wrong value while setting property)

QubesPropertyValueError ?

Dunno. Do we have other places, where we check values?

  • QubesNoTemplateError (template not found, like after incomplete backup)

May also cover incompatible template case (for example trying to create
HVM based on PV template). Or should it be QubesPropertyValueError?

*ValueError. QubesNoTemplateError will be raised when attempting to
start the domain.

regards, .-.
Wojtek Porczyk .-^' '^-.
Invisible Things Lab |'-.-^-.-'|
| | | |
I do not fear computers, | '-.-' |
I fear lack of them. '-._ : ,-'
-- Isaac Asimov `^-^-_>

Member

woju commented Oct 6, 2015

On Tue, Oct 06, 2015 at 04:18:07AM -0700, Marek Marczykowski-Górecki wrote:

- `QubesVMNotRunningError` (not active)
- `QubesVMNotStartedError`

What is the difference?

Paused state. For example .force_shutdown() should work when machine
is started but paused, but .run() requires machine that is running and
not paused. Both should fail when domain is powered off.

Perhaps QubesVMNotRunningError may be a child of
QubesVMNotStartedError.

- `QubesVMNotHaltedError`
- `QubesVMNotPausedError`
- `QubesVMNotSuspendedError`
  • QubesValueError (+ValueError; wrong value while setting property)

QubesPropertyValueError ?

Dunno. Do we have other places, where we check values?

  • QubesNoTemplateError (template not found, like after incomplete backup)

May also cover incompatible template case (for example trying to create
HVM based on PV template). Or should it be QubesPropertyValueError?

*ValueError. QubesNoTemplateError will be raised when attempting to
start the domain.

regards, .-.
Wojtek Porczyk .-^' '^-.
Invisible Things Lab |'-.-^-.-'|
| | | |
I do not fear computers, | '-.-' |
I fear lack of them. '-._ : ,-'
-- Isaac Asimov `^-^-_>

@woju

This comment has been minimized.

Show comment
Hide comment
@woju

woju Oct 6, 2015

Member

Or even TypeError.

Member

woju commented Oct 6, 2015

Or even TypeError.

@marmarek

This comment has been minimized.

Show comment
Hide comment
@marmarek

marmarek Oct 6, 2015

Member

On Tue, Oct 06, 2015 at 04:43:38AM -0700, Wojtek Porczyk wrote:

On Tue, Oct 06, 2015 at 04:18:07AM -0700, Marek Marczykowski-Górecki wrote:

- `QubesVMNotRunningError` (not active)
- `QubesVMNotStartedError`

What is the difference?

Paused state. For example .force_shutdown() should work when machine
is started but paused, but .run() requires machine that is running and
not paused. Both should fail when domain is powered off.

Perhaps QubesVMNotRunningError may be a child of
QubesVMNotStartedError.

+1

- `QubesVMNotHaltedError`
- `QubesVMNotPausedError`
- `QubesVMNotSuspendedError`
  • QubesValueError (+ValueError; wrong value while setting property)

QubesPropertyValueError ?

Dunno. Do we have other places, where we check values?

Not sure. Maybe better keep QubesValueError and ensure appropriate
message (containing word "property").

Or even TypeError.

QubesTypeError? Child of QubesValueError?

Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

Member

marmarek commented Oct 6, 2015

On Tue, Oct 06, 2015 at 04:43:38AM -0700, Wojtek Porczyk wrote:

On Tue, Oct 06, 2015 at 04:18:07AM -0700, Marek Marczykowski-Górecki wrote:

- `QubesVMNotRunningError` (not active)
- `QubesVMNotStartedError`

What is the difference?

Paused state. For example .force_shutdown() should work when machine
is started but paused, but .run() requires machine that is running and
not paused. Both should fail when domain is powered off.

Perhaps QubesVMNotRunningError may be a child of
QubesVMNotStartedError.

+1

- `QubesVMNotHaltedError`
- `QubesVMNotPausedError`
- `QubesVMNotSuspendedError`
  • QubesValueError (+ValueError; wrong value while setting property)

QubesPropertyValueError ?

Dunno. Do we have other places, where we check values?

Not sure. Maybe better keep QubesValueError and ensure appropriate
message (containing word "property").

Or even TypeError.

QubesTypeError? Child of QubesValueError?

Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

woju added a commit to woju/qubes-core-admin that referenced this issue Oct 14, 2015

core3: add different exceptions
From now on there are different exceptions which can be raise on
different occasions.

fixes QubesOS/qubes-issues#1279

woju added a commit to woju/qubes-core-admin that referenced this issue Oct 14, 2015

@woju woju closed this Oct 14, 2015

woju added a commit to woju/qubes-core-admin that referenced this issue Oct 16, 2015

core3: add different exceptions
From now on there are different exceptions which can be raise on
different occasions.

fixes QubesOS/qubes-issues#1279

woju added a commit to woju/qubes-core-admin that referenced this issue Oct 16, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment