本文整理汇总了Java中org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java ExceptionUtils.getStackTrace方法的具体用法?Java ExceptionUtils.getStackTrace怎么用?Java ExceptionUtils.getStackTrace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.exception.ExceptionUtils
的用法示例。
在下文中一共展示了ExceptionUtils.getStackTrace方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: invokeMethod
import org.apache.commons.lang3.exception.ExceptionUtils; //导入方法依赖的package包/类
@Override
void invokeMethod(AbstractTest instance, Method method, TestClassContext context, boolean isBeforeAfterGroup) {
AbstractWebServiceTest abstractWebServiceTest = (AbstractWebServiceTest) instance;
try {
method.setAccessible(true);
method.invoke(instance);
} catch (Throwable e) {
String errorMessage = format("Precondition method '%s' failed ", method.getName()) + "\n " + ExceptionUtils.getStackTrace(e);
if (isBeforeAfterGroup) {
abstractWebServiceTest.setPostponedBeforeAfterGroupFail(errorMessage, context.getTestContext());
} else {
abstractWebServiceTest.setPostponedTestFail(errorMessage);
}
new Report(errorMessage).allure();
}
}
示例2: handleIOException
import org.apache.commons.lang3.exception.ExceptionUtils; //导入方法依赖的package包/类
@ExceptionHandler(IOException.class)
public void handleIOException(HttpServletRequest request, Exception e, HttpServletResponse response) {
String stackFrames = ExceptionUtils.getStackTrace( e ) ;
if ( stackFrames.contains("ClientAbortException")) {
logger.info("ClientAbortException found: " + e.getMessage());
} else {
logger.warn( "{}: {}", request.getRequestURI(),CSAP.getCsapFilteredStackTrace( e ));
SimonManager.getCounter( CsapGlobalId.EXCEPTION.id ).increase();
try {
response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value() );
response.getWriter().print( HttpStatus.INTERNAL_SERVER_ERROR.value() + " : Exception during processing, examine server Logs");
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
示例3: logAndReturnException
import org.apache.commons.lang3.exception.ExceptionUtils; //导入方法依赖的package包/类
/**
* Clean return of Exception in JSon format & log Exception.
* @param request
* @param response
* @param out
* @param exception
*/
public static void logAndReturnException(HttpServletRequest request,
HttpServletResponse response, PrintWriter out, Exception exception) {
try {
JsonErrorReturn jsonErrorReturn = new JsonErrorReturn(response,
HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
JsonErrorReturn.ERROR_ACEQL_ERROR, exception.getMessage(),
ExceptionUtils.getStackTrace(exception));
out.println(jsonErrorReturn.build());
LoggerUtil.log(request, exception);
} catch (Exception e) {
// Should never happen
e.printStackTrace();
}
}
示例4: encode
import org.apache.commons.lang3.exception.ExceptionUtils; //导入方法依赖的package包/类
@Override
public void encode(BsonWriter writer, SyncError error, EncoderContext encoderContext) {
Document document= new Document();
if(error.getMessage()!=null && !error.getMessage().isEmpty()){
document.append(SyncAttrs.ERROR_MESSAGE, error.getMessage());
}
String fullStackTrace = ExceptionUtils.getStackTrace(error);
if(fullStackTrace!=null && !fullStackTrace.isEmpty()){
document.append(SyncAttrs.TRACE, fullStackTrace);
}
if(error.getThreadName()!=null && !error.getThreadName().isEmpty()){
document.append(SyncAttrs.THREAD_NAME, error.getThreadName());
}
documentCodec.encode(writer, document, encoderContext);
}
示例5: generateMultipleExceptionText
import org.apache.commons.lang3.exception.ExceptionUtils; //导入方法依赖的package包/类
public static String generateMultipleExceptionText(List<? extends Exception> exceptions, List<String> headlines) {
String text = "\n";
for (int i = 0; i < exceptions.size(); i++) {
text += headlines.get(i) + ": ";
text += ExceptionUtils.getStackTrace(exceptions.get(i));
text += "\n\n";
}
return text;
}
示例6: AbortDetails
import org.apache.commons.lang3.exception.ExceptionUtils; //导入方法依赖的package包/类
public AbortDetails(Exception ex, String abortMessage, String utilityName) {
if (ex == null) {
throw new IllegalArgumentException("Exception object cannot be null");
}
if (utilityName == null || utilityName.trim().equals("")) {
throw new IllegalArgumentException("Utility name cannot be null");
}
this.utilityName = utilityName;
this.abortMessage = abortMessage;
this.exceptionClass = ex.getClass().getSimpleName();
this.exceptionMessage = ex.getMessage();
this.exceptionStackTrace = ExceptionUtils.getStackTrace(ex);
}
示例7: executeAndRetry
import org.apache.commons.lang3.exception.ExceptionUtils; //导入方法依赖的package包/类
private void executeAndRetry() {
final long begin = System.currentTimeMillis();
try {
executeActivity();
} catch (Throwable t) {
final long diff = System.currentTimeMillis() - begin;
boolean aborted = isAborted(t);
boolean interrupted = isInterrupted(t);
final boolean runExecuting;
int nbRetry = 0;
if (!aborted && !interrupted && topProcessGroupLauncher.isStarted()) {
nbRetry = incrementNbRetries();
final String baseMessage = "Activity id=" + activityId + " retry=" + nbRetry + " (" + getActivityName() + ") : rollback done. Retrying? Msg='" + t.getMessage() + "'";
// On log tjrs le callstack, sinon on sait pas ce qu'il s'est passé.
// Le callstack enregistré dans le DbActivity est trop court...
final String msgWithCallstack = "\n" + ExceptionUtils.getStackTrace(t);
final RetryContext retryContext = new RetryContext(nbRetry, t, diff);
final boolean canRetry = getRetryPolicy().canRetry(retryContext);
if (!canRetry) {
// On log en ERROR parce que c'est terminé -> Error
LOGGER.error(msgWithCallstack);
// Si on a une erreur
treatErrorCase(t, nbRetry);
// Pas besoin de relancer, l'activité est terminée (max retry atteint)
runExecuting = false;
} else {
// On log en ERROR juste le message
LOGGER.error(baseMessage);
// On log en debug parce qu'on va retrying
LOGGER.debug(msgWithCallstack);
// Il faut essayer de relancer
runExecuting = true;
}
} else {
// Pas besoin de relancer, l'activité est ABORTED
runExecuting = false;
}
if (interrupted) {
topProcessGroupLauncher.setStatusForThread(TipiThreadStats.STATUS_INTERRUPTED);
} else if (aborted) {
topProcessGroupLauncher.setStatusForThread(TipiThreadStats.STATUS_ABORTED);
} else {
topProcessGroupLauncher.setStatusForThread(TipiThreadStats.STATUS_EXCEPTION + ":" + nbRetry);
}
topProcessGroupLauncher.removeRunning(activityId);
// On doit réessayer de lancer cette activité APRES l'avoir supprimé de
// la liste des RUNNING sinon elle va pas pouvoir être relancée
if (runExecuting) {
commandService.sendCommand(new RunExecutingActivitiesCommand());
}
} // try - catch : executeActivity
finally {
SecurityContextHolder.clearContext();
}
}
示例8: logout
import org.apache.commons.lang3.exception.ExceptionUtils; //导入方法依赖的package包/类
public static void logout(HttpServletRequest request,
HttpServletResponse response,
DatabaseConfigurator databaseConfigurator) throws IOException {
PrintWriter out = response.getWriter();
try {
response.setContentType("text/html");
String username = request.getParameter(HttpParameter.USERNAME);
String sessionId = request.getParameter(HttpParameter.SESSION_ID);
SessionConfigurator sessionConfigurator = ServerSqlManager
.getSessionManagerConfigurator();
sessionConfigurator.remove(sessionId);
if (!ConnectionStore.isStateless(username, sessionId)) {
ConnectionStore connectionStore = new ConnectionStore(username,
sessionId);
Connection connection = connectionStore.get();
connectionStore.remove();
ConnectionCloser.freeConnection(connection,
databaseConfigurator);
} else {
// Nothing to do for stateless connection as no connection
// created at this point
}
deleteBlobFiles(databaseConfigurator, username);
String jSonReturn = JsonOkReturn.build();
if (DEBUG) {
System.err.println("jSonReturn: " + jSonReturn);
System.err.println(sessionId);
}
out.println(jSonReturn);
} catch (Exception e) {
JsonErrorReturn errorReturn = new JsonErrorReturn(response,
HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
JsonErrorReturn.ERROR_ACEQL_FAILURE, e.getMessage(),
ExceptionUtils.getStackTrace(e));
out.println(errorReturn.build());
}
}
示例9: getExceptionStacktrace
import org.apache.commons.lang3.exception.ExceptionUtils; //导入方法依赖的package包/类
private String getExceptionStacktrace() {
return ExceptionUtils.getStackTrace(exception);
}
示例10: fatal
import org.apache.commons.lang3.exception.ExceptionUtils; //导入方法依赖的package包/类
private static Response fatal(final RqFallback req) {
return new RsWithStatus(
new RsText(ExceptionUtils.getStackTrace(req.throwable())),
HttpURLConnection.HTTP_INTERNAL_ERROR
);
}
示例11: error
import org.apache.commons.lang3.exception.ExceptionUtils; //导入方法依赖的package包/类
/**
* Logs the given arguments formatted using the given string format at error level, followed by the
* stack trace of the given {@link Throwable}
*
* @param throwable the stacktrace for this throwable will be included in full
* @param format String format, see {@link String#format(String, Object...)}
* @param args the arguments to format
* @see String#format(String, Object...)
* @see #willError()
*/
public static void error(Throwable throwable, String format, Object... args) {
if (willError()) {
String stacktrace = throwable == null ? "" : "\n" + ExceptionUtils.getStackTrace(throwable);
logger.severe(format(format, args) + stacktrace);
}
}