diff --git a/tests/cli/test_utils.py b/tests/cli/test_utils.py index 947fffa..39330e5 100644 --- a/tests/cli/test_utils.py +++ b/tests/cli/test_utils.py @@ -10,7 +10,9 @@ from hypothesis.strategies import ( text ) -from vdirsyncer.cli.utils import coerce_native + +from vdirsyncer import exceptions +from vdirsyncer.cli.utils import coerce_native, handle_cli_error @given(one_of( @@ -24,3 +26,14 @@ from vdirsyncer.cli.utils import coerce_native )) def test_coerce_native_fuzzing(s): coerce_native(s) + + +def test_handle_cli_error(capsys): + try: + raise exceptions.InvalidResponse('ayy lmao') + except: + handle_cli_error() + + out, err = capsys.readouterr() + assert 'returned something vdirsyncer doesn\'t understand' in err + assert 'ayy lmao' in err diff --git a/vdirsyncer/__init__.py b/vdirsyncer/__init__.py index 128ca67..1b6b5a1 100644 --- a/vdirsyncer/__init__.py +++ b/vdirsyncer/__init__.py @@ -6,6 +6,7 @@ vdirsyncer is a synchronization tool for vdir. See the README for more details. from __future__ import print_function PROJECT_HOME = 'https://github.com/pimutils/vdirsyncer' +BUGTRACKER_HOME = PROJECT_HOME + '/issues' DOCS_HOME = 'https://vdirsyncer.readthedocs.io/en/stable' try: diff --git a/vdirsyncer/cli/utils.py b/vdirsyncer/cli/utils.py index 8e03ddd..a2749d5 100644 --- a/vdirsyncer/cli/utils.py +++ b/vdirsyncer/cli/utils.py @@ -16,7 +16,7 @@ import click import click_threading from . import cli_logger -from .. import DOCS_HOME, exceptions +from .. import BUGTRACKER_HOME, DOCS_HOME, exceptions from ..sync import IdentConflict, StorageEmpty, SyncConflict from ..utils import expand_path, get_storage_init_args from ..utils.compat import to_native @@ -128,6 +128,15 @@ def handle_cli_error(status_name=None): 'configuration file and make sure you\'ve typed the pair name ' 'correctly'.format(pair_name=e.pair_name) ) + except exceptions.InvalidResponse as e: + cli_logger.error( + 'The server returned something vdirsyncer doesn\'t understand. ' + 'Error message: {!r}\n' + 'While this is most likely a serverside problem, the vdirsyncer ' + 'devs are generally interested in such bugs. Please report it in ' + 'the issue tracker at {}' + .format(e, BUGTRACKER_HOME) + ) except Exception as e: if status_name: msg = 'Unhandled exception occured for {}.'.format(