提交 e81374ad 编写于 作者: K kohsuke

... except such a method is already in the Functions class.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@9888 71c3de6d-444a-0410-be80-ed276b4c234a
上级 721ca127
......@@ -39,8 +39,6 @@ import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.Serializable;
import java.io.Writer;
import java.io.StringWriter;
import java.io.PrintWriter;
import java.io.OutputStreamWriter;
import java.net.URI;
import java.util.ArrayList;
......@@ -852,9 +850,7 @@ public final class FilePath implements Serializable {
throw e; // the remote side completed successfully, so the error must be local
} catch (ExecutionException x) {
// report both errors
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));
throw new IOException2(sw.toString(),x);
throw new IOException2(Functions.printThrowable(e),x);
} catch (TimeoutException _) {
// remote is hanging
throw e;
......
......@@ -234,9 +234,7 @@ public final class PluginManager extends AbstractModelObject {
}
public String getExceptionString() {
StringWriter sw = new StringWriter();
cause.printStackTrace(new PrintWriter(sw));
return sw.toString();
return Functions.printThrowable(cause);
}
}
}
......@@ -788,17 +788,6 @@ public class Util {
}
}
/**
* Obtains the stack dump as a string.
*
* @since 1.222
*/
public static String toString(Throwable t) {
StringWriter sw = new StringWriter();
t.printStackTrace(new PrintWriter(sw));
return sw.toString();
}
public static final SimpleDateFormat XS_DATETIME_FORMATTER = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
// Note: RFC822 dates must not be localized!
......
......@@ -8,6 +8,7 @@ import hudson.FilePath.FileCallable;
import hudson.Launcher;
import hudson.Util;
import hudson.XmlFile;
import hudson.Functions;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.BuildListener;
......@@ -1244,16 +1245,13 @@ public class SubversionSCM extends SCM implements Serializable {
} else
ok();
} catch (SVNException e) {
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));
String message="";
message += "Unable to access "+Util.escape(url)+" : "+Util.escape( e.getErrorMessage().getFullMessage());
message += " <a href='#' id=svnerrorlink onclick='javascript:" +
"document.getElementById(\"svnerror\").style.display=\"block\";" +
"document.getElementById(\"svnerrorlink\").style.display=\"none\";" +
"return false;'>(show details)</a>";
message += "<pre id=svnerror style='display:none'>"+sw+"</pre>";
message += "<pre id=svnerror style='display:none'>"+Functions.printThrowable(e)+"</pre>";
message += " (Maybe you need to <a target='_new' href='"+req.getContextPath()+"/scm/SubversionSCM/enterCredential?"+url+"'>enter credential</a>?)";
message += "<br>";
logger.log(Level.INFO, "Failed to access subversion repository "+url,e);
......
......@@ -2,6 +2,7 @@ package hudson.tasks;
import hudson.FilePath;
import hudson.Util;
import hudson.Functions;
import hudson.model.*;
import hudson.scm.ChangeLogSet;
......@@ -227,9 +228,7 @@ public class MailSender<P extends AbstractProject<P, B>, B extends AbstractBuild
}
} catch (IOException e) {
// somehow failed to read the contents of the log
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));
buf.append("Failed to access build log\n\n").append(sw);
buf.append("Failed to access build log\n\n").append(Functions.printThrowable(e));
}
msg.setText(buf.toString());
......
package hudson.util;
import hudson.Functions;
import java.io.PrintWriter;
import java.io.StringWriter;
......@@ -19,8 +21,6 @@ public class HudsonFailedToLoad extends ErrorObject {
}
public String getStackTrace() {
StringWriter sw = new StringWriter();
exception.printStackTrace(new PrintWriter(sw));
return sw.toString();
return Functions.printThrowable(exception);
}
}
package hudson.util;
import hudson.Functions;
import java.io.StringWriter;
import java.io.PrintWriter;
......@@ -20,8 +22,6 @@ public class InsufficientPermissionDetected extends ErrorObject {
}
public String getExceptionTrace() {
StringWriter sw = new StringWriter();
exception.printStackTrace(new PrintWriter(sw));
return sw.toString();
return Functions.printThrowable(exception);
}
}
package hudson.util;
import hudson.Functions;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
......@@ -21,9 +23,7 @@ public class NoTempDir extends ErrorObject {
}
public String getStackTrace() {
StringWriter sw = new StringWriter();
exception.printStackTrace(new PrintWriter(sw));
return sw.toString();
return Functions.printThrowable(exception);
}
public String getTempDir() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册