Use message for HTTP error code when response payload is not valid JSON (#13854)

Fixes #13853

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
pull/13861/head
Jacob Laursen 2022-12-06 08:45:31 +01:00 committed by GitHub
parent fdc23e07dd
commit be6bfb0f9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -272,8 +272,13 @@ public class ApiBridgeHandler extends BaseBridgeHandler {
logger.trace("executeUri returned : code {} body {}", statusCode, responseBody);
if (statusCode != Code.OK) {
ApiError error = deserializer.deserialize(ApiError.class, responseBody);
throw new NetatmoException(error);
try {
ApiError error = deserializer.deserialize(ApiError.class, responseBody);
throw new NetatmoException(error);
} catch (NetatmoException e) {
logger.debug("Error deserializing payload from error response", e);
throw new NetatmoException(statusCode.getMessage());
}
}
return deserializer.deserialize(clazz, responseBody);
} catch (NetatmoException e) {