From be6bfb0f9ba6b4f15ea3a136a3d730b59890a163 Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Tue, 6 Dec 2022 08:45:31 +0100 Subject: [PATCH] Use message for HTTP error code when response payload is not valid JSON (#13854) Fixes #13853 Signed-off-by: Jacob Laursen --- .../netatmo/internal/handler/ApiBridgeHandler.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/ApiBridgeHandler.java b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/ApiBridgeHandler.java index d23d5aa7f..38531f488 100644 --- a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/ApiBridgeHandler.java +++ b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/ApiBridgeHandler.java @@ -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) {