From 7b3f839d3420a7711c6ebdb208f7c8ba3c5ebd19 Mon Sep 17 00:00:00 2001 From: andre Date: Mon, 20 Jul 2020 23:37:04 -0700 Subject: [PATCH] Fixed handling of status code 41 and surfacing errors on retry --- sublime/adapters/subsonic/adapter.py | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/sublime/adapters/subsonic/adapter.py b/sublime/adapters/subsonic/adapter.py index 7abd9fa..684be2d 100644 --- a/sublime/adapters/subsonic/adapter.py +++ b/sublime/adapters/subsonic/adapter.py @@ -169,19 +169,13 @@ class SubsonicAdapter(Adapter): "Double check the server address." ) except ServerError as e: - if e.status_code == 41: - # as per subsonic api docs, description of status_code 41 is - # "Token authentication not supported for LDAP users." so fall - # back to password auth - config_store["salt_auth"] = False - logging.warn( - "Salted auth no supported for LDAP users, falling back to " - "regular password auth" - ) - elif e.status_code == 10 and config_store["salt_auth"]: - # if salt auth is not enabled, server will return error server - # error with status_code 10 since it'll interpret it as a - # missing (password) parameter + if e.status_code in [10, 41] and config_store["salt_auth"]: + # status code 10: if salt auth is not enabled, server will + # return error server error with status_code 10 since it'll + # interpret it as a missing (password) parameter + # status code 41: as per subsonic api docs, description of + # status_code 41 is "Token authentication not supported for LDAP + # users." so fall back to password auth try: config_store["salt_auth"] = False tmp_adapter = SubsonicAdapter( @@ -196,8 +190,12 @@ class SubsonicAdapter(Adapter): "Salted auth not supported, falling back to regular " "password auth" ) - except ServerError: + except ServerError as retry_e: config_store["salt_auth"] = True + errors["__ping__"] = ( + "Error connecting to the server.\n" + f"Error {retry_e.status_code}: {str(retry_e)}" + ) else: errors["__ping__"] = ( "Error connecting to the server.\n"