From 0859d47df0816f75be41327cf298848127a2ed43 Mon Sep 17 00:00:00 2001 From: Bianca Steffes Date: Mon, 15 Nov 2021 08:29:50 +0100 Subject: [PATCH] Added further details for error on wrong response code --- export/src/export/Main.java | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/export/src/export/Main.java b/export/src/export/Main.java index dc689d5..928ac76 100644 --- a/export/src/export/Main.java +++ b/export/src/export/Main.java @@ -7,6 +7,7 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; +import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.net.HttpURLConnection; @@ -55,7 +56,7 @@ public class Main */ private static Triplet refreshInfo; - private static void writeError(String text) + private static void writeError(String text, InputStream errorStream) { if (errorFile == null) { @@ -66,11 +67,32 @@ public class Main { bout.write(text); bout.newLine(); + if (errorStream!= null) + { + BufferedReader bin = new BufferedReader(new InputStreamReader(errorStream)); + + String errorLine = bin.readLine(); + while (errorLine != null) + { + bout.write(" **** "+errorLine); + bout.newLine(); + errorLine = bin.readLine(); + } + + bin.close(); + } } catch (IOException e) { } } + + private static void writeError(String text) + { + writeError(text, null); + } + + /** * For testing: ensures the test requests are used @@ -478,7 +500,7 @@ public class Main // excluded error messages appearing on missing streams and reached rate limit if (responseCode != HttpURLConnection.HTTP_NOT_FOUND && responseCode != httpCodeLimitReached) { - writeError("Athlete: " + athleteId + " Wrong response code: " + responseCode); + writeError("Athlete: " + athleteId + " Wrong response code: " + responseCode, connection.getErrorStream()); } throw new ResponseCodeWrongException(responseCode); }