Browse Source

Added further details for error on wrong response code

master
Bianca Steffes 2 years ago
parent
commit
0859d47df0
  1. 26
      export/src/export/Main.java

26
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);
}

Loading…
Cancel
Save