improved exception message
added response body if availaibe, which may contain the server's stack trace
@@ -19,8 +19,12 @@ package won.protocol.rest;
import org.apache.jena.query.Dataset;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.http.*;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
import org.springframework.web.client.HttpClientErrorException;
+import org.springframework.web.client.HttpServerErrorException;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;
@@ -114,6 +118,11 @@ public abstract class LinkedDataRestClient
if(e instanceof HttpClientErrorException){
throw e;
}
+ if (e instanceof HttpServerErrorException) {
+ throw new IllegalArgumentException(
+ MessageFormat.format(
+ "caught a HttpServerErrorException exception, for {0}. Underlying error message is: {1}, response Body: {2}", resourceURI, e.getMessage(), ((HttpServerErrorException) e).getResponseBodyAsString()), e);
+ }
throw new IllegalArgumentException(
MessageFormat.format(
"caught a clientHandler exception, " +
