Skip to content

Commit

Permalink
qvm-prefs: Don't falsely report 'no such property'
Browse files Browse the repository at this point in the history
Previously we printed a 'no such property' error for all exceptions that
are an instance of AttributeError which includes
QubesPropertyAccessError and therefore generated confusing error
messages. Print them only in case of QubesNoSuchPropertyError.

Fixes QubesOS/qubes-issues#8666
Related to QubesOS/qubes-issues#5005
  • Loading branch information
HW42 committed Dec 11, 2023
1 parent e789256 commit dbecdec
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions qubesadmin/tools/qvm_prefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def process_actions(parser, args, target):
args.value = ''
try:
setattr(target, args.property, args.value)
except AttributeError:
except qubesadmin.exc.QubesNoSuchPropertyError:
parser.error('no such property: {!r}'.format(args.property))
except qubesadmin.exc.QubesException as e:
parser.error_runtime(e)
Expand All @@ -134,7 +134,7 @@ def process_actions(parser, args, target):
if args.delete:
try:
delattr(target, args.property)
except AttributeError:
except qubesadmin.exc.QubesNoSuchPropertyError:
parser.error('no such property: {!r}'.format(args.property))
except qubesadmin.exc.QubesException as e:
parser.error_runtime(e)
Expand All @@ -144,7 +144,7 @@ def process_actions(parser, args, target):
value = getattr(target, args.property)
if value is not None:
print(str(value))
except AttributeError:
except qubesadmin.exc.QubesNoSuchPropertyError:
parser.error('no such property: {!r}'.format(args.property))
except qubesadmin.exc.QubesException as e:
parser.error_runtime(e)
Expand Down

0 comments on commit dbecdec

Please sign in to comment.