From 34464f28c4b831d8b18dafcf08870450c0c83644 Mon Sep 17 00:00:00 2001 From: Eliot Berriot <contact@eliotberriot.com> Date: Thu, 23 May 2019 15:00:00 +0200 Subject: [PATCH] Improved error landing when not logged in --- funkwhale_cli/cli.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/funkwhale_cli/cli.py b/funkwhale_cli/cli.py index 70252b5..1948581 100644 --- a/funkwhale_cli/cli.py +++ b/funkwhale_cli/cli.py @@ -60,10 +60,18 @@ def async_command(f): _async_reraise = kwargs.pop("_async_reraise", False) try: return loop.run_until_complete(f(*args, **kwargs)) - except (exceptions.FunkwhaleError, aiohttp.client_exceptions.ClientError) as e: + except (aiohttp.client_exceptions.ClientError) as e: if _async_reraise: raise - raise click.ClickException(str(e)) + message = str(e) + if hasattr(e, 'status') and e.status == 401: + message = "Remote answered with {}, ensure your are logged in first".format(e.status) + raise click.ClickException(message) + except (exceptions.FunkwhaleError) as e: + if _async_reraise: + raise + message = str(e) + raise click.ClickException(message) else: raise -- GitLab