From 7707ea538c770ff29e2307ddb1870fd107d98cd6 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Wed, 12 Apr 2023 01:18:05 +0200 Subject: [PATCH] fix FilesCacheMode validator (cherry picked from commit 0f923c8c4a03016a8b8159dcafec2ca8860e8a49) --- src/borg/helpers/parseformat.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/borg/helpers/parseformat.py b/src/borg/helpers/parseformat.py index 0a1818c0f..cdfb145ac 100644 --- a/src/borg/helpers/parseformat.py +++ b/src/borg/helpers/parseformat.py @@ -140,11 +140,13 @@ def FilesCacheMode(s): VALID_MODES = ('cis', 'ims', 'cs', 'ms', 'cr', 'mr', 'd', 's') # letters in alpha order entries = set(s.strip().split(',')) if not entries <= set(ENTRIES_MAP): - raise ValueError('cache mode must be a comma-separated list of: %s' % ','.join(sorted(ENTRIES_MAP))) + raise argparse.ArgumentTypeError( + 'cache mode must be a comma-separated list of: %s' % ','.join(sorted(ENTRIES_MAP)) + ) short_entries = {ENTRIES_MAP[entry] for entry in entries} mode = ''.join(sorted(short_entries)) if mode not in VALID_MODES: - raise ValueError('cache mode short must be one of: %s' % ','.join(VALID_MODES)) + raise argparse.ArgumentTypeError('cache mode short must be one of: %s' % ','.join(VALID_MODES)) return mode