Added further details for error on wrong response code
This commit is contained in:
@@ -7,6 +7,7 @@ import java.io.FileInputStream;
|
|||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
@@ -55,7 +56,7 @@ public class Main
|
|||||||
*/
|
*/
|
||||||
private static Triplet refreshInfo;
|
private static Triplet refreshInfo;
|
||||||
|
|
||||||
private static void writeError(String text)
|
private static void writeError(String text, InputStream errorStream)
|
||||||
{
|
{
|
||||||
if (errorFile == null)
|
if (errorFile == null)
|
||||||
{
|
{
|
||||||
@@ -66,11 +67,32 @@ public class Main
|
|||||||
{
|
{
|
||||||
bout.write(text);
|
bout.write(text);
|
||||||
bout.newLine();
|
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)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void writeError(String text)
|
||||||
|
{
|
||||||
|
writeError(text, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For testing: ensures the test requests are used
|
* 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
|
// excluded error messages appearing on missing streams and reached rate limit
|
||||||
if (responseCode != HttpURLConnection.HTTP_NOT_FOUND && responseCode != httpCodeLimitReached)
|
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);
|
throw new ResponseCodeWrongException(responseCode);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user