Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better errors messages #3195

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ private ClientHttpResponse doHttpRequestWithRetry(final HttpHeaders headers) thr
throw e;
}
}
} while (true); }
} while (true);
}

private ClientHttpResponse executeCallbacksAndRequest(final ClientHttpRequest requestToExecute)
throws IOException {
Expand Down
13 changes: 10 additions & 3 deletions core/src/main/java/org/mapfish/print/http/HttpRequestFetcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,21 @@ private CachedClientHttpResponse(final ClientHttpResponse originalResponse) thro
this.statusText = originalResponse.getStatusText();
this.cachedFile =
File.createTempFile("cacheduri", null, HttpRequestFetcher.this.temporaryDirectory);
LOGGER.debug("Caching URI resource to {}", this.cachedFile);
try (OutputStream os = Files.newOutputStream(this.cachedFile.toPath())) {
IOUtils.copy(originalResponse.getBody(), os);
InputStream body = originalResponse.getBody();
LOGGER.debug("Get from input stream {}, for response {}",
body.getClass(), originalResponse.getClass());
LOGGER.debug("Body available: {}", body.available());
IOUtils.copy(body, os);
}
}

@Override
@Nonnull
public InputStream getBody() throws IOException {
if (this.body == null) {
LOGGER.debug("Loading cached URI resource from {}", this.cachedFile);
this.body = new FileInputStream(this.cachedFile);
}
return this.body;
Expand Down Expand Up @@ -128,6 +134,7 @@ public void close() {
if (this.body != null) {
try {
this.body.close();
this.body = null;
} catch (IOException e) {
// ignored
}
Expand Down Expand Up @@ -227,13 +234,13 @@ public InputStream getBody() {

@Override
public int getRawStatusCode() {
return 500;
return 999;
}

@Override
@Nonnull
public String getStatusText() {
return e.getMessage();
return String.format("IOException: %s", e.getMessage());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ public void close() {
getBody();
if (inputStream != null) {
inputStream.close();
inputStream = null;
}
} catch (IOException e) {
LOGGER.error("Error occurred while trying to retrieve Http Response {} in order to close it.",
Expand Down
Loading