From 2ddf6f47ad9e114a5b5bfc2c151396a125907fd6 Mon Sep 17 00:00:00 2001 From: Tan Jin Date: Tue, 30 Mar 2021 13:30:33 +0800 Subject: [PATCH] Fix: fix a bug where null exception results in looping gif --- src/main/java/seedu/us/among/logic/request/EndpointCaller.java | 2 +- src/main/java/seedu/us/among/logic/request/Request.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/seedu/us/among/logic/request/EndpointCaller.java b/src/main/java/seedu/us/among/logic/request/EndpointCaller.java index a31ee68dde1..e42cea4866e 100644 --- a/src/main/java/seedu/us/among/logic/request/EndpointCaller.java +++ b/src/main/java/seedu/us/among/logic/request/EndpointCaller.java @@ -81,7 +81,7 @@ public Response callEndpoint() throws RequestException, AbortRequestException { } else { throw new AbortRequestException(MESSAGE_CONNECTION_ERROR); } - } catch (IOException e) { + } catch (Exception e) { logger.warning(StringUtil.getDetails(e)); throw new RequestException(MESSAGE_GENERAL_ERROR); } finally { diff --git a/src/main/java/seedu/us/among/logic/request/Request.java b/src/main/java/seedu/us/among/logic/request/Request.java index bf2e213d69b..6658689d9f7 100644 --- a/src/main/java/seedu/us/among/logic/request/Request.java +++ b/src/main/java/seedu/us/among/logic/request/Request.java @@ -106,7 +106,8 @@ private String formatEntity(HttpEntity entity) throws IOException { String responseEntity = ""; if (entity != null) { responseEntity = EntityUtils.toString(entity); - if (entity.getContentType().getValue().toLowerCase().contains("application/json")) { + if (entity.getContentType() != null + && entity.getContentType().getValue().toLowerCase().contains("application/json")) { responseEntity = JsonUtil.toPrettyPrintJsonString(responseEntity); } }