From 97708ab3da42b5a6581edd1d3c77340ce8218688 Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Thu, 13 Apr 2017 18:41:37 +0200 Subject: [PATCH] Fix shitty exception --- vdirsyncer/cli/config.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/vdirsyncer/cli/config.py b/vdirsyncer/cli/config.py index 0d68baf..893c42d 100644 --- a/vdirsyncer/cli/config.py +++ b/vdirsyncer/cli/config.py @@ -273,6 +273,9 @@ class PairConfig(object): @cached_property def partial_sync(self): partial_sync = self._partial_sync + # We need to use UserError here because ValueError is not + # caught at the time this is expanded. + if partial_sync is not None: cls_a, _ = storage_class_from_config(self.config_a) cls_b, _ = storage_class_from_config(self.config_b) @@ -281,14 +284,17 @@ class PairConfig(object): not self.config_a.get('read_only', False) and \ not cls_b.read_only and \ not self.config_b.get('read_only', False): - raise ValueError('`partial_sync` is only effective if one ' - 'storage is read-only.') + raise exceptions.UserError( + '`partial_sync` is only effective if one storage is ' + 'read-only. Use `read_only = true` in exactly one storage ' + 'section.' + ) if partial_sync is None: partial_sync = 'revert' if partial_sync not in ('ignore', 'revert', 'error'): - raise ValueError('Invalid value for `partial_sync`.') + raise exceptions.UserError('Invalid value for `partial_sync`.') return partial_sync