Don't show strack trace on stdout but instead log it

This commit is contained in:
Laurent Clouet
2017-04-19 21:23:12 +02:00
parent 8b92cba01e
commit 6a2cc2b8a6
2 changed files with 74 additions and 27 deletions

View File

@@ -492,8 +492,11 @@ public class Client {
this.server.HTTPSendFile(this.server.getPage("error") + args, temp_file.getAbsolutePath()); this.server.HTTPSendFile(this.server.getPage("error") + args, temp_file.getAbsolutePath());
temp_file.delete(); temp_file.delete();
} }
catch (Exception e1) { catch (Exception e) {
e1.printStackTrace(); StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
this.log.debug("Client::sendError Exception " + e + " stacktrace: " + sw.toString());
// no exception should be raised to actual launcher (applet or standalone) // no exception should be raised to actual launcher (applet or standalone)
} }

View File

@@ -155,7 +155,10 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager
this.log.debug("Server::stayAlive can not connect to server"); this.log.debug("Server::stayAlive can not connect to server");
} }
catch (IOException e) { catch (IOException e) {
e.printStackTrace(); StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
this.log.debug("Server::stayAlive IOException " + e + " stacktrace: " + sw.toString());
} }
} }
try { try {
@@ -165,6 +168,10 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager
return; return;
} }
catch (Exception e) { catch (Exception e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
this.log.debug("Server::stayAlive Exception " + e + " stacktrace: " + sw.toString());
return; return;
} }
} }
@@ -393,7 +400,10 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager
} }
} }
catch (Exception e) { catch (Exception e) {
e.printStackTrace(); StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
this.log.debug("Server::requestJob Exception " + e + " stacktrace: " + sw.toString());
} }
String[] job_node_require_attribute = { "id", "archive_md5", "path", "use_gpu", "frame", "name", "extras", "password" }; String[] job_node_require_attribute = { "id", "archive_md5", "path", "use_gpu", "frame", "name", "extras", "password" };
@@ -515,11 +525,17 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager
((HttpsURLConnection) connection).setHostnameVerifier(this); ((HttpsURLConnection) connection).setHostnameVerifier(this);
} }
catch (NoSuchAlgorithmException e) { catch (NoSuchAlgorithmException e) {
e.printStackTrace(); StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
this.log.debug("Server::HTTPRequest NoSuchAlgorithmException " + e + " stacktrace: " + sw.toString());
return null; return null;
} }
catch (KeyManagementException e) { catch (KeyManagementException e) {
e.printStackTrace(); StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
this.log.debug("Server::HTTPRequest KeyManagementException " + e + " stacktrace: " + sw.toString());
return null; return null;
} }
} }
@@ -596,7 +612,7 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager
StringWriter sw = new StringWriter(); StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw)); e.printStackTrace(new PrintWriter(sw));
this.log.error("Server::HTTPGetFile exception " + e + " stacktrace " + sw.toString()); this.log.error("Server::HTTPGetFile Exception " + e + " stacktrace " + sw.toString());
} }
this.log.debug("Server::HTTPGetFile(" + url_ + ", ...) will failed (end of function)"); this.log.debug("Server::HTTPGetFile(" + url_ + ", ...) will failed (end of function)");
return -2; return -2;
@@ -693,29 +709,44 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager
dos.flush(); dos.flush();
dos.close(); dos.close();
} }
catch (MalformedURLException ex) { catch (MalformedURLException e) {
this.log.error("Server::HTTPSendFile, exception MalformedURLException " + ex); StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
this.log.error("Server::HTTPSendFile, MalformedURLException " + e + " stacktrace " + sw.toString());
return ServerCode.UNKNOWN; return ServerCode.UNKNOWN;
} }
catch (IOException ioe) { catch (IOException e) {
this.log.error("Server::HTTPSendFile, exception IOException " + ioe); StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
this.log.error("Server::HTTPSendFile, IOException " + e + " stacktrace " + sw.toString());
return ServerCode.UNKNOWN; return ServerCode.UNKNOWN;
} }
catch (Exception e6) { catch (OutOfMemoryError e) {
this.log.error("Server::HTTPSendFile, exception Exception " + e6); StringWriter sw = new StringWriter();
return ServerCode.UNKNOWN; PrintWriter pw = new PrintWriter(sw);
} e.printStackTrace(pw);
catch (OutOfMemoryError e6) { this.log.error("Server::HTTPSendFile, OutOfMemoryError " + e + " stacktrace " + sw.toString());
this.log.error("Server::HTTPSendFile, exception Exception " + e6);
return ServerCode.JOB_VALIDATION_ERROR_UPLOAD_FAILED; return ServerCode.JOB_VALIDATION_ERROR_UPLOAD_FAILED;
} }
catch (Exception e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
this.log.error("Server::HTTPSendFile, Exception " + e + " stacktrace " + sw.toString());
return ServerCode.UNKNOWN;
}
int r; int r;
try { try {
r = conn.getResponseCode(); r = conn.getResponseCode();
} }
catch (IOException e1) { catch (IOException e) {
e1.printStackTrace(); StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
this.log.debug("Server::HTTPSendFile IOException " + e + " stacktrace: " + sw.toString());
return ServerCode.UNKNOWN; return ServerCode.UNKNOWN;
} }
String contentType = conn.getContentType(); String contentType = conn.getContentType();
@@ -725,8 +756,11 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager
try { try {
in = new DataInputStream(conn.getInputStream()); in = new DataInputStream(conn.getInputStream());
} }
catch (IOException e1) { catch (IOException e) {
e1.printStackTrace(); StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
this.log.debug("Server::HTTPSendFile IOException " + e + " stacktrace: " + sw.toString());
return ServerCode.UNKNOWN; return ServerCode.UNKNOWN;
} }
Document document = null; Document document = null;
@@ -734,15 +768,24 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager
document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(in); document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(in);
} }
catch (SAXException e) { catch (SAXException e) {
e.printStackTrace(); StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
this.log.debug("Server::HTTPSendFile SAXException " + e + " stacktrace: " + sw.toString());
return ServerCode.UNKNOWN; return ServerCode.UNKNOWN;
} }
catch (IOException e) { catch (IOException e) {
e.printStackTrace(); StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
this.log.debug("Server::HTTPSendFile IOException " + e + " stacktrace: " + sw.toString());
return ServerCode.UNKNOWN; return ServerCode.UNKNOWN;
} }
catch (ParserConfigurationException e) { catch (ParserConfigurationException e) {
e.printStackTrace(); StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
this.log.debug("Server::HTTPSendFile ParserConfigurationException " + e + " stacktrace: " + sw.toString());
return ServerCode.UNKNOWN; return ServerCode.UNKNOWN;
} }
@@ -803,9 +846,10 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager
return ret; return ret;
} }
catch (Exception e) { catch (Exception e) {
System.err.println("Server::getLastRender exception " + e); StringWriter sw = new StringWriter();
e.printStackTrace(); PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
this.log.debug("Server::getLastRender Exception " + e + " stacktrace: " + sw.toString());
} }
return null; return null;
} }