mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-26 15:21:41 +01:00
Handle JsonSyntaxException when parsing error messages (#13083)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
parent
f5eabf0ba2
commit
4f1fb4ed51
@ -151,12 +151,15 @@ public class GroupePSAConnectApi {
|
|||||||
|
|
||||||
switch (statusCode) {
|
switch (statusCode) {
|
||||||
case HttpStatus.NOT_FOUND_404:
|
case HttpStatus.NOT_FOUND_404:
|
||||||
ErrorObject error = gson.fromJson(response.getContentAsString(), ErrorObject.class);
|
ErrorObject error = null;
|
||||||
String message = (error != null) ? error.getMessage() : null;
|
try {
|
||||||
if (message == null) {
|
error = gson.fromJson(response.getContentAsString(), ErrorObject.class);
|
||||||
message = "Unknown";
|
} 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.FORBIDDEN_403:
|
||||||
case HttpStatus.UNAUTHORIZED_401:
|
case HttpStatus.UNAUTHORIZED_401:
|
||||||
|
Loading…
Reference in New Issue
Block a user