本文整理了Java中hudson.Functions.printThrowable()
方法的一些代码示例,展示了Functions.printThrowable()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Functions.printThrowable()
方法的具体详情如下:
包路径:hudson.Functions
类名称:Functions
方法名:printThrowable
[英]Prints a stack trace from an exception into a readable form. Unlike Throwable#printStackTrace(PrintWriter), this implementation follows the suggestion of JDK-6507809 to produce a linear trace even when Throwable#getCause is used.
[中]将异常中的堆栈跟踪打印为可读形式。与Throwable#printStackTrace(PrintWriter)不同,此实现遵循JDK-6507809的建议,即使使用Throwable#getCause,也会生成线性跟踪。
代码示例来源:origin: jenkinsci/jenkins
public String getProblemStackTrace() {
return Functions.printThrowable(problem);
}
}
代码示例来源:origin: jenkinsci/jenkins
public String getExceptionString() {
return Functions.printThrowable(cause);
}
}
代码示例来源:origin: jenkinsci/jenkins
public String getStackTraceString() {
return Functions.printThrowable(this);
}
代码示例来源:origin: jenkinsci/jenkins
@Override
public String toString() {
String s = path+" owned by "+holder.getName()+" from "+new Date(time);
if(quick) s+=" (quick)";
s+="\n"+Functions.printThrowable(source);
return s;
}
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Like {@link Throwable#printStackTrace(PrintWriter)} but using {@link #printThrowable} format.
* @param t an exception to print
* @param pw the log
* @since 2.43
*/
public static void printStackTrace(@CheckForNull Throwable t, @Nonnull PrintWriter pw) {
pw.println(printThrowable(t).trim());
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Like {@link Throwable#printStackTrace(PrintStream)} but using {@link #printThrowable} format.
* @param t an exception to print
* @param ps the log
* @since 2.43
*/
public static void printStackTrace(@CheckForNull Throwable t, @Nonnull PrintStream ps) {
ps.println(printThrowable(t).trim());
}
代码示例来源:origin: jenkinsci/jenkins
@Override public String toString() {
return Messages.OfflineCause_connection_was_broken_(Functions.printThrowable(cause));
}
}
代码示例来源:origin: jenkinsci/jenkins
private void addStatus(UnknownHostException e) {
statuses.add("<pre>"+ Functions.xmlEscape(Functions.printThrowable(e))+"</pre>");
}
代码示例来源:origin: jenkinsci/jenkins
@Override
public Void visitType(TypeElement e, Void aVoid) {
if(!e.getModifiers().contains(Modifier.ABSTRACT)) {
Element sc = asElement(e.getSuperclass());
if (sc!=null && ((TypeElement)sc).getQualifiedName().contentEquals("hudson.Plugin")) {
try {
write(e);
} catch (IOException x) {
processingEnv.getMessager().printMessage(Kind.ERROR, Functions.printThrowable(x), e);
}
}
}
return super.visitType(e, aVoid);
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Partially formats a log record.
* @return date, source, level, message+thrown
* @see SimpleFormatter#format(LogRecord)
*/
private static String[] logRecordPreformat(LogRecord r) {
String source;
if (r.getSourceClassName() == null) {
source = r.getLoggerName();
} else {
if (r.getSourceMethodName() == null) {
source = r.getSourceClassName();
} else {
source = r.getSourceClassName() + " " + r.getSourceMethodName();
}
}
String message = new SimpleFormatter().formatMessage(r) + "\n";
Throwable x = r.getThrown();
return new String[] {
String.format("%1$tb %1$td, %1$tY %1$tl:%1$tM:%1$tS %1$Tp", new Date(r.getMillis())),
source,
r.getLevel().getLocalizedName(),
x == null ? message : message + printThrowable(x) + "\n"
};
}
代码示例来源:origin: jenkinsci/jenkins
@Override
protected FilePathRule parse(String line) {
line = line.trim();
if (line.isEmpty()) return null;
line = line.replace("<BUILDDIR>","<JOBDIR>/builds/<BUILDID>");
line = line.replace("<BUILDID>","(?:[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]_[0-9][0-9]-[0-9][0-9]-[0-9][0-9]|[0-9]+)");
line = line.replace("<JOBDIR>","<JENKINS_HOME>/jobs/.+");
line = line.replace("<JENKINS_HOME>","\\Q"+Jenkins.getInstance().getRootDir().getPath()+"\\E");
// config file is always /-separated even on Windows, so bring it back to \-separation.
// This is done in the context of regex, so it has to be \\, which means in the source code it is \\\\
if (isWindows()) line = line.replace("/","\\\\");
Matcher m = PARSER.matcher(line);
if (!m.matches())
throw new Failure("Invalid filter rule line: "+line);
try {
return new FilePathRule(
Pattern.compile(m.group(3)),
createOpMatcher(m.group(2)),
m.group(1).equals("allow"));
} catch (Exception e) {
throw new Failure("Invalid filter rule line: "+line+"\n"+ Functions.printThrowable(e));
}
}
代码示例来源:origin: jenkinsci/jenkins
r.put(e.getKey(), e.getValue().get(endTime-System.currentTimeMillis(), TimeUnit.MILLISECONDS));
} catch (Exception x) {
r.put(e.getKey(), Collections.singletonMap("Failed to retrieve thread dump", Functions.printThrowable(x)));
代码示例来源:origin: jenkinsci/jenkins
} catch (Exception e) {
connectionStates.put(ConnectionStatus.UPDATE_SITE, ConnectionStatus.FAILED);
statuses.add(Functions.printThrowable(e));
error = e;
代码示例来源:origin: jenkinsci/jenkins
private static FormValidation _error(Kind kind, Throwable e, String message) {
if (e==null) return _errorWithMarkup(Util.escape(message),kind);
return _errorWithMarkup(Util.escape(message)+
" <a href='#' class='showDetails'>"
+ Messages.FormValidation_Error_Details()
+ "</a><pre style='display:none'>"
+ Util.escape(Functions.printThrowable(e)) +
"</pre>",kind
);
}
代码示例来源:origin: jenkinsci/jenkins
private static FormFillFailure _error(FormValidation.Kind kind, Throwable e, String message) {
if (e == null) {
return _errorWithMarkup(Util.escape(message), kind);
}
return _errorWithMarkup(Util.escape(message) +
" <a href='#' class='showDetails'>"
+ Messages.FormValidation_Error_Details()
+ "</a><pre style='display:none'>"
+ Util.escape(Functions.printThrowable(e)) +
"</pre>", kind
);
}
代码示例来源:origin: jenkinsci/configuration-as-code-plugin
public CNode describe(Owner instance, ConfigurationContext context) throws ConfiguratorException {
final Configurator c = context.lookup(type);
if (c == null) {
return new Scalar("FAILED TO EXPORT " + instance.getClass().getName()+"#"+name +
": No configurator found for type " + type);
}
try {
Object o = getValue(instance);
if (o == null) {
return null;
}
if (multiple) {
Sequence seq = new Sequence();
if (o.getClass().isArray()) o = Arrays.asList((Object[]) o);
for (Object value : (Iterable) o) {
seq.add(c.describe(value, context));
}
return seq;
}
return c.describe(o, context);
} catch (Exception | /* Jenkins.getDescriptorOrDie */AssertionError e) {
// Don't fail the whole export, prefer logging this error
return new Scalar("FAILED TO EXPORT " + instance.getClass().getName() + "#" + name + ": \n" + Functions.printThrowable(e));
}
}
代码示例来源:origin: jenkinsci/jenkins
@Override
public Authentication autoLogin(HttpServletRequest request, HttpServletResponse response) {
if(Jenkins.getInstance().isDisableRememberMe()){
cancelCookie(request, response, null);
return null;
}else {
try {
// we use a patched version of the super.autoLogin
String rememberMeValue = findRememberMeCookieValue(request, response);
if (rememberMeValue == null) {
return null;
}
return retrieveAuthFromCookie(request, response, rememberMeValue);
} catch (Exception e) {
cancelCookie(request, response, "Failed to handle remember-me cookie: " + Functions.printThrowable(e));
return null;
}
}
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Deletes the build when the button is pressed.
*/
@RequirePOST
public void doDoDelete( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
checkPermission(DELETE);
// We should not simply delete the build if it has been explicitly
// marked to be preserved, or if the build should not be deleted
// due to dependencies!
String why = getWhyKeepLog();
if (why!=null) {
sendError(Messages.Run_UnableToDelete(getFullDisplayName(), why), req, rsp);
return;
}
try{
delete();
}
catch(IOException ex){
req.setAttribute("stackTraces", Functions.printThrowable(ex));
req.getView(this, "delete-retry.jelly").forward(req, rsp);
return;
}
rsp.sendRedirect2(req.getContextPath()+'/' + getParent().getUrl());
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
/**
* Like {@link Throwable#printStackTrace(PrintWriter)} but using {@link #printThrowable} format.
* @param t an exception to print
* @param pw the log
* @since 2.43
*/
public static void printStackTrace(@CheckForNull Throwable t, @Nonnull PrintWriter pw) {
pw.println(printThrowable(t).trim());
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
private static FormValidation _error(Kind kind, Throwable e, String message) {
if (e==null) return _errorWithMarkup(Util.escape(message),kind);
return _errorWithMarkup(Util.escape(message)+
" <a href='#' class='showDetails'>"
+ Messages.FormValidation_Error_Details()
+ "</a><pre style='display:none'>"
+ Util.escape(Functions.printThrowable(e)) +
"</pre>",kind
);
}
内容来源于网络,如有侵权,请联系作者删除!