List of usage examples for java.lang Throwable getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:forge.error.BugReporter.java
/** * Shows exception information in a format ready to post to the forum as a * crash report. Uses the exception's message as the reason if message is * null./*from w w w .j av a2 s. c om*/ */ public static void reportException(final Throwable ex, final String message) { if (ex == null) { return; } if (message != null) { System.err.printf("%s > %s%n", FThreads.debugGetCurrThreadId(), message); } System.err.print(FThreads.debugGetCurrThreadId() + " > "); ex.printStackTrace(); final StringBuilder sb = new StringBuilder(); sb.append("Description: [describe what you were doing when the crash occurred]\n\n"); buildSpoilerHeader(sb, ex.getClass().getSimpleName()); sb.append("\n\n"); if (null != message && !message.isEmpty()) { sb.append(FThreads.debugGetCurrThreadId()).append(" > ").append(message).append("\n"); } final StringWriter sw = new StringWriter(); final PrintWriter pw = new PrintWriter(sw); ex.printStackTrace(pw); final String swStr = sw.toString(); if (ex instanceof StackOverflowError && swStr.length() >= STACK_OVERFLOW_MAX_MESSAGE_LEN) { // most likely a cycle. only take first portion so the message // doesn't grow too large to post sb.append(swStr, 0, STACK_OVERFLOW_MAX_MESSAGE_LEN); sb.append("\n... (truncated)"); } else { sb.append(swStr); } buildSpoilerFooter(sb); GuiBase.getInterface().showBugReportDialog("Report a crash", sb.toString(), true); }
From source file:fiftyfive.wicket.util.LoggingUtils.java
/** * Writes to the logger a best-guess at the most concise description of * the exception by first unwrapping it (see {@link #unwrap upwrap}), then * writes a large amount of information regarding the current Wicket state * (see {@link #dumpWicketState dumpWicketState}), and finally writes the * full stack traces of the entire exception chain. * <p>//from w w w . ja v a 2 s. co m * Example logger output: * <pre class="example"> * ParseException: Unparseable date: "1xxx07" * * Request: * URL = wicket/bookmarkable/fiftyfive.wicket.examples.formtest.FormTestPage?0&initialMonth=10.2007&startDate=1xxx07&endDate=11.10.2007 * Handler = RenderPageRequestHandler * Component = FormTestPage * Duration = 485 milliseconds * Session: * ID = 1sxy938y7qoqq942z4pnuqdqt * Info = TODO: Your session info goes here * Size = 716 bytes * Duration = 310 milliseconds * Application: * Active Sessions = 1 (1 peak) * Memory Usage = 25M used, 40M free, 533M max * IP Address = 172.16.1.14 * Uptime = 10.9 seconds * Headers: * Host = localhost:8080 * User-Agent = Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-us) AppleWebKit/533.18.1 (KHTML, like Gecko) Version/5.0.2 Safari/533.18.5 * Accept = application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 * Cache-Control = max-age=0 * Accept-Language = en-us * Accept-Encoding = gzip, deflate * Cookie = JSESSIONID=1217fv4qjpnbnv1ewzzmonevh * Connection = keep-alive * * Message: Error calling method: public java.util.Date fiftyfive.wicket.examples.formtest.FormTestPage$1.getStartDate() on object: [ [Component id = calendar-control]] * * Root cause: * * java.text.ParseException: Unparseable date: "1xxx07" * at java.text.DateFormat.parse(DateFormat.java:337) * at fiftyfive.wicket.examples.formtest.FormTestPage$1.getStartDate(FormTestPage.java:82) * at java.lang.reflect.Method.invoke(Method.java:597) * at org.apache.wicket.util.lang.PropertyResolver$MethodGetAndSet.getValue(PropertyResolver.java:1112) * at org.apache.wicket.util.lang.PropertyResolver$ObjectAndGetSetter.getValue(PropertyResolver.java:637) * at org.apache.wicket.util.lang.PropertyResolver.getValue(PropertyResolver.java:96) * at org.apache.wicket.model.AbstractPropertyModel.getObject(AbstractPropertyModel.java:122) * at fiftyfive.wicket.datetime.RestrictedDatePicker.configure(RestrictedDatePicker.java:168) * at org.apache.wicket.extensions.yui.calendar.DatePicker.renderHead(DatePicker.java:260) * at org.apache.wicket.Component.renderHead(Component.java:2627) * at org.apache.wicket.markup.renderStrategy.ParentFirstHeaderRenderStrategy$1.component(ParentFirstHeaderRenderStrategy.java:70) * at org.apache.wicket.markup.renderStrategy.ParentFirstHeaderRenderStrategy$1.component(ParentFirstHeaderRenderStrategy.java:66) * at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:143) * at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:161) * at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:161) * at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:161) * at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:117) * at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:193) * at org.apache.wicket.MarkupContainer.visitChildren(MarkupContainer.java:941) * at org.apache.wicket.markup.renderStrategy.ParentFirstHeaderRenderStrategy.renderChildHeaders(ParentFirstHeaderRenderStrategy.java:64) * at org.apache.wicket.markup.renderStrategy.AbstractHeaderRenderStrategy.renderHeader(AbstractHeaderRenderStrategy.java:125) * at org.apache.wicket.markup.html.internal.HtmlHeaderContainer.onComponentTagBody(HtmlHeaderContainer.java:140) * at org.apache.wicket.Component.renderComponent(Component.java:2518) * at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1527) * at org.apache.wicket.Component.render_(Component.java:2380) * at org.apache.wicket.Component.render(Component.java:2307) * at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1466) * at org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1589) * at org.apache.wicket.Page.onRender(Page.java:1139) * at org.apache.wicket.Component.render_(Component.java:2380) * at org.apache.wicket.Component.render(Component.java:2307) * at org.apache.wicket.Page.renderPage(Page.java:1289) * at org.apache.wicket.request.handler.render.WebPageRenderer.renderPage(WebPageRenderer.java:131) * at org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:199) * at org.apache.wicket.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:149) * at org.apache.wicket.request.RequestHandlerStack.executeRequestHandler(RequestHandlerStack.java:84) * at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:206) * at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:248) * at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:131) * at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:184) * at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) * at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:83) * at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) * at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) * at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388) * at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) * at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182) * at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765) * at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:440) * at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230) * at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114) * at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) * at org.mortbay.jetty.Server.handle(Server.java:326) * at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542) * at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:926) * at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549) * at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212) * at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404) * at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410) * at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582) * * * Complete stack: * * org.apache.wicket.WicketRuntimeException: Error calling method: public java.util.Date fiftyfive.wicket.examples.formtest.FormTestPage$1.getStartDate() on object: [ [Component id = calendar-control]] * at org.apache.wicket.util.lang.PropertyResolver$MethodGetAndSet.getValue(PropertyResolver.java:1116) * at org.apache.wicket.util.lang.PropertyResolver$ObjectAndGetSetter.getValue(PropertyResolver.java:637) * at org.apache.wicket.util.lang.PropertyResolver.getValue(PropertyResolver.java:96) * at org.apache.wicket.model.AbstractPropertyModel.getObject(AbstractPropertyModel.java:122) * at fiftyfive.wicket.datetime.RestrictedDatePicker.configure(RestrictedDatePicker.java:168) * at org.apache.wicket.extensions.yui.calendar.DatePicker.renderHead(DatePicker.java:260) * at org.apache.wicket.Component.renderHead(Component.java:2627) * at org.apache.wicket.markup.renderStrategy.ParentFirstHeaderRenderStrategy$1.component(ParentFirstHeaderRenderStrategy.java:70) * at org.apache.wicket.markup.renderStrategy.ParentFirstHeaderRenderStrategy$1.component(ParentFirstHeaderRenderStrategy.java:66) * at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:143) * at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:161) * at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:161) * at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:161) * at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:117) * at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:193) * at org.apache.wicket.MarkupContainer.visitChildren(MarkupContainer.java:941) * at org.apache.wicket.markup.renderStrategy.ParentFirstHeaderRenderStrategy.renderChildHeaders(ParentFirstHeaderRenderStrategy.java:64) * at org.apache.wicket.markup.renderStrategy.AbstractHeaderRenderStrategy.renderHeader(AbstractHeaderRenderStrategy.java:125) * at org.apache.wicket.markup.html.internal.HtmlHeaderContainer.onComponentTagBody(HtmlHeaderContainer.java:140) * at org.apache.wicket.Component.renderComponent(Component.java:2518) * at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1527) * at org.apache.wicket.Component.render_(Component.java:2380) * at org.apache.wicket.Component.render(Component.java:2307) * at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1466) * at org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1589) * at org.apache.wicket.Page.onRender(Page.java:1139) * at org.apache.wicket.Component.render_(Component.java:2380) * at org.apache.wicket.Component.render(Component.java:2307) * at org.apache.wicket.Page.renderPage(Page.java:1289) * at org.apache.wicket.request.handler.render.WebPageRenderer.renderPage(WebPageRenderer.java:131) * at org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:199) * at org.apache.wicket.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:149) * at org.apache.wicket.request.RequestHandlerStack.executeRequestHandler(RequestHandlerStack.java:84) * at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:206) * at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:248) * at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:131) * * java.lang.RuntimeException: java.text.ParseException: Unparseable date: "1xxx07" * at fiftyfive.wicket.examples.formtest.FormTestPage$1.getStartDate(FormTestPage.java:87) * at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) * at java.lang.reflect.Method.invoke(Method.java:597) * at org.apache.wicket.util.lang.PropertyResolver$MethodGetAndSet.getValue(PropertyResolver.java:1112) * at org.apache.wicket.util.lang.PropertyResolver$ObjectAndGetSetter.getValue(PropertyResolver.java:637) * at org.apache.wicket.util.lang.PropertyResolver.getValue(PropertyResolver.java:96) * at org.apache.wicket.model.AbstractPropertyModel.getObject(AbstractPropertyModel.java:122) * at fiftyfive.wicket.datetime.RestrictedDatePicker.configure(RestrictedDatePicker.java:168) * at org.apache.wicket.extensions.yui.calendar.DatePicker.renderHead(DatePicker.java:260) * at org.apache.wicket.Component.renderHead(Component.java:2627) * at org.apache.wicket.markup.renderStrategy.ParentFirstHeaderRenderStrategy$1.component(ParentFirstHeaderRenderStrategy.java:70) * at org.apache.wicket.markup.renderStrategy.ParentFirstHeaderRenderStrategy$1.component(ParentFirstHeaderRenderStrategy.java:66) * at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:143) * at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:161) * at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:161) * at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:161) * at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:117) * at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:193) * at org.apache.wicket.MarkupContainer.visitChildren(MarkupContainer.java:941) * at org.apache.wicket.markup.renderStrategy.ParentFirstHeaderRenderStrategy.renderChildHeaders(ParentFirstHeaderRenderStrategy.java:64) * at org.apache.wicket.markup.renderStrategy.AbstractHeaderRenderStrategy.renderHeader(AbstractHeaderRenderStrategy.java:125) * at org.apache.wicket.markup.html.internal.HtmlHeaderContainer.onComponentTagBody(HtmlHeaderContainer.java:140) * at org.apache.wicket.Component.renderComponent(Component.java:2518) * at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1527) * at org.apache.wicket.Component.render_(Component.java:2380) * at org.apache.wicket.Component.render(Component.java:2307) * at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1466) * at org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1589) * at org.apache.wicket.Page.onRender(Page.java:1139) * at org.apache.wicket.Component.render_(Component.java:2380) * at org.apache.wicket.Component.render(Component.java:2307) * at org.apache.wicket.Page.renderPage(Page.java:1289) * at org.apache.wicket.request.handler.render.WebPageRenderer.renderPage(WebPageRenderer.java:131) * at org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:199) * at org.apache.wicket.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:149) * at org.apache.wicket.request.RequestHandlerStack.executeRequestHandler(RequestHandlerStack.java:84) * at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:206) * at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:248) * at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:131)</pre> */ public static void logException(Logger logger, Exception e) { Args.notNull(logger, "logger"); Args.notNull(e, "e"); try { Throwable unwrapped = unwrap(e); logger.error(String.format("%s: %s%n%n%s%n%n%s", Classes.simpleName(unwrapped.getClass()), unwrapped.getMessage(), dumpWicketState(), Strings.toString(e))); } catch (Exception loggingEx) { // We should never arrive here, because it means that something // went terribly wrong in our logging code. Since our code failed, // fall back to simple logging so that Wicket error handling // can continue uninterrupted. LOGGER.error("Unexpected exception during logging", loggingEx); logger.error("RuntimeException", e); } }
From source file:com.tomtom.speedtools.rest.GeneralExceptionMapper.java
/** * Static function to map an exception to a proper (asynchronous) response. * * @param log Logger to log information, warning or error message to. * @param exception Exception to be processed. * @return Status response./* w w w . j a v a 2 s. co m*/ */ @SuppressWarnings("deprecation") @Nonnull public static Response toResponse(@Nonnull final Logger log, @Nonnull final Throwable exception) { assert log != null; assert exception != null; //noinspection SuspiciousMethodCalls final Tuple<Boolean, Status> tuple = customExceptionsMap.get(exception.getClass()); if (tuple != null) { if (tuple.getValue1()) { // Internal server error. return toResponseApiException(Level.ERROR, log, exception); } else { // Bad API call. return toResponseBadApiCall(log, tuple.getValue2(), exception); } } /** * Don't always throw an Error. This exception may be caused by asking for a wrong URL. * We need to catch those properly and log them as Informational, or Warnings, at most. * * Exceptions as a result of the way the call was issued (external cause, usually * a bad API call). These are never errors, just informational. */ if (exception instanceof ApiBadRequestException) { return toResponseApiValidationError(log, (ApiBadRequestException) exception); } /** * Api exceptions other than bad request. */ else if (exception instanceof ApiForbiddenException) { return toResponseBadApiCall(log, Status.FORBIDDEN, exception); } else if (exception instanceof ApiInternalException) { return toResponseBadApiCall(log, Status.INTERNAL_SERVER_ERROR, exception); } else if (exception instanceof ApiNotFoundException) { return toResponseBadApiCall(log, Status.NOT_FOUND, exception); } else if (exception instanceof ApiNotImplementedException) { return toResponseBadApiCall(log, HttpServletResponse.SC_NOT_IMPLEMENTED, exception); } else if (exception instanceof ApiConflictException) { return toResponseBadApiCall(log, Status.CONFLICT, exception); } else if (exception instanceof ApiUnauthorizedException) { return toResponseBadApiCall(log, Status.UNAUTHORIZED, exception); } /** * Rest-easy exceptions (deprecated). */ else if (exception instanceof org.jboss.resteasy.spi.BadRequestException) { return toResponseBadApiCall(log, Status.BAD_REQUEST, exception); } else if (exception instanceof org.jboss.resteasy.spi.NotFoundException) { return toResponseBadApiCall(log, Status.NOT_FOUND, exception); } else if (exception instanceof org.jboss.resteasy.spi.NotAcceptableException) { return toResponseBadApiCall(log, Status.NOT_ACCEPTABLE, exception); } else if (exception instanceof org.jboss.resteasy.spi.MethodNotAllowedException) { return toResponseBadApiCall(log, Status.FORBIDDEN, exception); } else if (exception instanceof org.jboss.resteasy.spi.UnauthorizedException) { return toResponseBadApiCall(log, Status.UNAUTHORIZED, exception); } else if (exception instanceof org.jboss.resteasy.spi.UnsupportedMediaTypeException) { return toResponseBadApiCall(log, Status.UNSUPPORTED_MEDIA_TYPE, exception); } /** * Javax exceptions. */ else if (exception instanceof javax.ws.rs.BadRequestException) { return toResponseBadApiCall(log, Status.BAD_REQUEST, exception); } else if (exception instanceof javax.ws.rs.NotFoundException) { return toResponseBadApiCall(log, Status.NOT_FOUND, exception); } else if (exception instanceof javax.ws.rs.NotAcceptableException) { return toResponseBadApiCall(log, Status.NOT_ACCEPTABLE, exception); } else if ((exception instanceof javax.ws.rs.NotAllowedException) || (exception instanceof javax.ws.rs.ForbiddenException)) { return toResponseBadApiCall(log, Status.FORBIDDEN, exception); } else if (exception instanceof javax.ws.rs.NotAuthorizedException) { return toResponseBadApiCall(log, Status.UNAUTHORIZED, exception); } else if (exception instanceof javax.ws.rs.NotSupportedException) { return toResponseBadApiCall(log, Status.UNSUPPORTED_MEDIA_TYPE, exception); } /** * System specific exception, such as "entity not found". These are not * always errors, either, but some are. Inspect on case-by-case! */ else if (exception instanceof AskTimeoutException) { return toResponseApiException(Level.WARN, log, exception); } else if (exception instanceof BSONException) { return toResponseApiException(Level.ERROR, log, exception); } /** * Jackson unmarshall exceptions typically thrown from a {@link XmlAdapter} wrap a more specific exception. */ else //noinspection ObjectEquality if ((exception instanceof JsonMappingException) && (exception.getCause() != null) && (exception.getCause() != exception)) { /** * Call toResponse again, with the cause of the exception. */ //noinspection TailRecursion return toResponse(log, exception.getCause()); } /** * Some other system failure. */ else { return toResponseApiException(Level.ERROR, log, exception); } }
From source file:com.zimbra.soap.SoapCommandUtil.java
private static String formatServiceException(ServiceException e) { Throwable cause = e.getCause(); return "ERROR: " + e.getCode() + " (" + e.getMessage() + ")" + (cause == null ? "" : " (cause: " + cause.getClass().getName() + " " + cause.getMessage() + ")"); }
From source file:org.pgptool.gui.tools.ConsoleExceptionUtils.java
public static String getAllMessages(Throwable t) { if (t == null) return ""; StringBuffer ret = new StringBuffer(); Throwable cur = t; while (cur != null) { if (cur == cur.getCause()) break; if (ret.length() > 0) { ret.append(" -> "); }/*from w ww. j a v a 2 s. co m*/ if (cur instanceof FieldValidationException) { FieldValidationException fve = (FieldValidationException) cur; ret.append(buildMessageForFve(fve, LocaleContextHolder.getLocale())); } else if (cur instanceof HasMessageCode) { ret.append(I18nUtils.buildMessage((HasMessageCode) cur, ac())); } else { try { String className = cur.getClass().getName(); String messageMappingForClassName = Messages.get(className, cur.getMessage()); if (className.equals(messageMappingForClassName)) { throw new NoSuchMessageException(className); } ret.append(messageMappingForClassName); } catch (NoSuchMessageException nfe) { ret.append(cur.getLocalizedMessage()); } } cur = cur.getCause(); } return ret.toString(); }
From source file:com.github.nukesparrow.htmlunit.DebuggingWebConnection.java
protected static Map boxThrowable(Throwable ex) { Map m = new LinkedHashMap(); m.put("time", System.currentTimeMillis()); m.put("message", ex.getMessage()); m.put("class", ex.getClass().getCanonicalName()); StringWriter sw = new StringWriter(); ex.printStackTrace(new PrintWriter(sw, true)); m.put("stack", sw.toString()); return m;/*from w ww .j a v a2s. c o m*/ }
From source file:at.alladin.rmbt.qos.testserver.util.TestServerConsole.java
/** * //from w w w .ja v a2 s. c o m * @param info * @param t * @param verboseLevelNeeded * @param service */ public static void errorReport(String errorReportKey, String info, Throwable t, int verboseLevelNeeded, TestServerServiceEnum service) { StringWriter stackTrace = new StringWriter(); t.printStackTrace(new PrintWriter(stackTrace)); if (!errorReportMap.containsKey(errorReportKey)) { errorReportMap.putIfAbsent(errorReportKey, new ErrorReport( info + ": [" + t.getClass().getCanonicalName() + " - " + t.getMessage() + "]", new Date())); } ErrorReport er = errorReportMap.get(errorReportKey); er.increaseCounter(); LoggingService.fatal(t, info, service); }
From source file:com.kamuda.common.exception.ExceptionUtils.java
/** * <p>Finds a <code>Throwable</code> by method name.</p> * //from w ww.j a v a2s .co m * @param throwable the exception to examine * @param methodName the name of the method to find and invoke * @return the wrapped exception, or <code>null</code> if not found */ private static Throwable getCauseUsingMethodName(Throwable throwable, String methodName) { Method method = null; try { method = throwable.getClass().getMethod(methodName, null); } catch (NoSuchMethodException ignored) { } catch (SecurityException ignored) { } if (method != null && Throwable.class.isAssignableFrom(method.getReturnType())) { try { return (Throwable) method.invoke(throwable, ArrayHelper.EMPTY_OBJECT_ARRAY); } catch (IllegalAccessException ignored) { } catch (IllegalArgumentException ignored) { } catch (InvocationTargetException ignored) { } } return null; }
From source file:com.machinepublishers.jbrowserdriver.Util.java
static void handleException(Throwable throwable) { if (throwable != null) { String message = throwable.getMessage(); if ((throwable instanceof UncheckedExecutionException || throwable instanceof RemoteException) && throwable.getCause() != null) { throwable = throwable.getCause(); message = throwable.getMessage(); }//from w w w . jav a 2 s.co m if (throwable instanceof WebDriverException && throwable instanceof RuntimeException) { //Wrap the exception to ensure complete/helpful stack trace info and also preserve the original subtype try { throwable = throwable.getClass().getConstructor(String.class, Throwable.class) .newInstance(message, throwable); } catch (Throwable t) { try { throwable = throwable.getClass().getConstructor(Throwable.class).newInstance(throwable); } catch (Throwable t2) { } } throw (RuntimeException) throwable; } throw new WebDriverException(message, throwable); } }
From source file:org.apache.asterix.api.http.server.ResultUtil.java
public static void printError(PrintWriter pw, Throwable e, boolean comma) { Throwable rootCause = getRootCause(e); if (rootCause == null) { rootCause = e;/*ww w . j a va2s . c o m*/ } final boolean addStack = false; pw.print("\t\""); pw.print(AbstractQueryApiServlet.ResultFields.ERRORS.str()); pw.print("\": [{ \n"); printField(pw, QueryServiceServlet.ErrorField.CODE.str(), "1"); final String msg = rootCause.getMessage(); printField(pw, QueryServiceServlet.ErrorField.MSG.str(), JSONUtil.escape(msg != null ? msg : rootCause.getClass().getSimpleName()), addStack); pw.print(comma ? "\t}],\n" : "\t}]\n"); }