diff --git a/bundles/org.openhab.binding.groupepsa/src/main/java/org/openhab/binding/groupepsa/internal/rest/api/GroupePSAConnectApi.java b/bundles/org.openhab.binding.groupepsa/src/main/java/org/openhab/binding/groupepsa/internal/rest/api/GroupePSAConnectApi.java index 15bfcff264a..815ee15c598 100644 --- a/bundles/org.openhab.binding.groupepsa/src/main/java/org/openhab/binding/groupepsa/internal/rest/api/GroupePSAConnectApi.java +++ b/bundles/org.openhab.binding.groupepsa/src/main/java/org/openhab/binding/groupepsa/internal/rest/api/GroupePSAConnectApi.java @@ -151,12 +151,15 @@ public class GroupePSAConnectApi { switch (statusCode) { case HttpStatus.NOT_FOUND_404: - ErrorObject error = gson.fromJson(response.getContentAsString(), ErrorObject.class); - String message = (error != null) ? error.getMessage() : null; - if (message == null) { - message = "Unknown"; + ErrorObject error = null; + try { + error = gson.fromJson(response.getContentAsString(), ErrorObject.class); + } catch (JsonSyntaxException e) { + throw new GroupePSACommunicationException("Error in received JSON: " + getRootCause(e).getMessage(), + e); } - throw new GroupePSACommunicationException(statusCode, message); + String message = (error == null) ? null : error.getMessage(); + throw new GroupePSACommunicationException(statusCode, message == null ? "Unknown" : message); case HttpStatus.FORBIDDEN_403: case HttpStatus.UNAUTHORIZED_401: