mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-25 14:55:55 +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) {
|
||||
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:
|
||||
|
Loading…
Reference in New Issue
Block a user