Skip to content

Commit 88c8ac9

Browse files
authored
Merge pull request #61 from indigo-dc/new_exception
New exception
2 parents 3c87d43 + 38e26b8 commit 88c8ac9

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<maven-javadoc-plugin.version>2.10.3</maven-javadoc-plugin.version>
2121
<maven-checkstyle-plugin.version>2.17</maven-checkstyle-plugin.version>
2222
<mockserver-netty.version>3.10.4</mockserver-netty.version>
23-
<jacoco-maven-plugin.version>0.7.7.201606060606</jacoco-maven-plugin.version>
23+
<jacoco-maven-plugin.version>0.8.2</jacoco-maven-plugin.version>
2424
<mockito.version>2.0.70-beta</mockito.version>
2525
</properties>
2626

src/main/java/es/upv/i3m/grycap/im/rest/client/ImClient.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
import java.nio.file.Path;
3333

34+
import javax.ws.rs.ProcessingException;
3435
import javax.ws.rs.ServerErrorException;
3536
import javax.ws.rs.WebApplicationException;
3637
import javax.ws.rs.client.Client;
@@ -173,7 +174,17 @@ public <T> T delete(final String path, final Class<T> type,
173174
private static ResponseError
174175
createReponseError(WebApplicationException exception) {
175176
Response clientReponse = exception.getResponse();
176-
return clientReponse.readEntity(ResponseError.class);
177+
178+
ResponseError response;
179+
try {
180+
response = clientReponse.readEntity(ResponseError.class);
181+
} catch (ProcessingException e) {
182+
// if the error msg is not the expected JSON, get it as String
183+
String errorMessage = clientReponse.readEntity(String.class);
184+
response = new ResponseError(errorMessage, clientReponse.getStatus());
185+
}
186+
187+
return response;
177188
}
178189

179190
/**

src/test/java/es/upv/i3m/grycap/im/rest/client/ImClientTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package es.upv.i3m.grycap.im.rest.client;
1818

1919
import es.upv.i3m.grycap.ImTestWatcher;
20-
import es.upv.i3m.grycap.im.exceptions.ImClientServerErrorException;
2120
import es.upv.i3m.grycap.im.exceptions.ImClientErrorException;
2221
import es.upv.i3m.grycap.im.exceptions.ImClientException;
2322
import es.upv.i3m.grycap.im.pojo.ResponseError;
@@ -35,7 +34,6 @@ public class ImClientTest extends ImTestWatcher {
3534
private static final String AUTH_FILE_PATH = "./src/test/resources/auth.dat";
3635
private static final Integer EXPECTED_ERROR_CODE = 404;
3736
private static final String EXPECTED_ERROR_MESSAGE = "Not found: '/'";
38-
private static final String IM_FAKE_PROVIDER_URL = "http://localhost:1234";
3937

4038
private ImClient getImClient() {
4139
return imClient;

0 commit comments

Comments
 (0)