From c0f1a6b4e86a6c7f907a4288b5d5ae34f3a01c4e Mon Sep 17 00:00:00 2001 From: Bahtiar `kalkin-` Gadimov Date: Tue, 16 Aug 2016 19:18:19 +0200 Subject: [PATCH] qvm-block & qvm-pool add better Exception handling --- qubes/tools/qvm_block.py | 9 +++++++-- qubes/tools/qvm_pool.py | 7 ++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/qubes/tools/qvm_block.py b/qubes/tools/qvm_block.py index 855370c2..76bfe1e9 100644 --- a/qubes/tools/qvm_block.py +++ b/qubes/tools/qvm_block.py @@ -228,8 +228,13 @@ def get_parser(): def main(args=None): '''Main routine of :program:`qvm-block`.''' - args = get_parser().parse_args(args) - args.func(args) + parser = get_parser() + try: + args = parser.parse_args(args) + args.func(args) + except qubes.exc.QubesException as e: + parser.print_error(e.message) + return 1 if __name__ == '__main__': diff --git a/qubes/tools/qvm_pool.py b/qubes/tools/qvm_pool.py index 0444d56d..ca289f6d 100644 --- a/qubes/tools/qvm_pool.py +++ b/qubes/tools/qvm_pool.py @@ -187,7 +187,12 @@ def main(args=None): command line. ''' parser = get_parser() - args = parser.parse_args(args) + try: + args = parser.parse_args(args) + except qubes.exc.QubesException as e: + parser.print_error(e.message) + return 1 + if args.command is None or args.command == 'list': list_pools(args.app) elif args.command == 'add':