List of usage examples for java.lang Exception getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:net.kamhon.ieagle.aop.LoggerThrowsAdvice.java
private boolean isNeedToLog(Exception ex) { String className = ex.getClass().getName(); for (String exceptionNotToLog : exceptionsNotToLog) { if (className.equals(exceptionNotToLog)) { return false; }//ww w . j a v a 2 s. com } return true; }
From source file:com.clustercontrol.selfcheck.SelfCheckTask.java
/** * ???/*from w ww .ja v a 2 s . com*/ */ @Override public void run() { /** */ JpaTransactionManager tm = null; /** ? */ if (m_log.isDebugEnabled()) m_log.debug("executing self-check. (" + toString() + ")"); try { tm = new JpaTransactionManager(); tm.begin(); // ?? monitor.execute(); tm.commit(); } catch (Exception e) { m_log.warn("run() : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e); if (tm != null) tm.rollback(); } finally { if (tm != null) tm.close(); } if (m_log.isDebugEnabled()) m_log.debug("selfcheck scheduler task is executed. (" + toString() + ")"); }
From source file:net.dbyrne.natenberg.Server.java
@SuppressWarnings("unchecked") private JSONObject newErrorMsg(Exception e) { JSONObject error = new JSONObject(); error.put("error", e.getClass() + ":" + e.getMessage()); return error; }
From source file:com.doitnext.swing.widgets.json.JSONJTreeNodeTest.java
@Test public void pushTest() throws Exception { InputStream resource = null;/*from ww w . j a v a2s .c o m*/ StringWriter sw = null; try { resource = this.getClass().getClassLoader().getResourceAsStream(fileName); sw = new StringWriter(); IOUtils.copy(resource, sw); String json = sw.toString(); sw.close(); sw = null; resource.close(); resource = null; JsonElement rootElt = new JsonParser().parse(json); JSONJTreeNode root = new JSONJTreeNode(null, -1, rootElt); JsonElement converted = root.asJsonElement(); String expected = rootElt.toString(); String actual = converted.toString(); Assert.assertEquals("Json does not match", expected, actual); if (expectedError != null) throw new IllegalArgumentException( "We didnt' get an " + expectedError.getClass().getName() + " exception as expected.", expectedError); } catch (Exception e) { if (!e.getClass().isInstance(expectedError)) throw e; } finally { if (resource != null) resource.close(); if (sw != null) sw.close(); } }
From source file:coyote.dx.web.worker.HtmlWorker.java
/** * @see coyote.dx.web.worker.AbstractWorker#marshalResponseBody(coyote.dx.web.Response, org.apache.http.HttpResponse, coyote.dx.web.Parameters) *//*from www . ja v a 2s .c o m*/ @Override public void marshalResponseBody(final Response workerResponse, final HttpResponse httpResponse, final Parameters params) { try { // Use Content-Encoding to properly parse the body final org.apache.http.entity.ContentType ctype = org.apache.http.entity.ContentType .getOrDefault(httpResponse.getEntity()); final String body = EntityUtils.toString(httpResponse.getEntity(), ctype.getCharset()); final Document document = Jsoup.parse(body); workerResponse.setDocument(document); return; } catch (final Exception e) { Log.error("Problems parsing HTML: " + e.getClass().getSimpleName() + " - " + e.getMessage()); } super.marshalResponseBody(workerResponse, httpResponse, params); }
From source file:throwsaop.SimpleThrowsAdvice.java
public void afterThrowing(Exception ex) throws Throwable { System.out.println("***"); System.out.println("Generic exception capture"); System.out.println("Caught `" + ex.getClass().getName() + "` exception"); System.out.println("***"); System.out.println(""); }
From source file:com.twitter.common.util.RetryingRunnable.java
@Override public void run() { try {// w w w .j a va 2s . c om task.execute(); } catch (Exception e) { if (e.getClass().isAssignableFrom(exceptionClass)) { if (tryNum < numTries) { commandExecutor.execute(name, task, exceptionClass, numTries - 1, retryDelay); } else { LOG.log(Level.INFO, "Giving up on task: " + name + " " + "after " + "trying " + numTries + " times" + ".", e); } } else { LOG.log(Level.INFO, "Giving up on task: " + name + " after trying " + numTries + " times. " + "due to unhandled exception ", e); throw Throwables.propagate(e); } } }
From source file:de.tudarmstadt.lt.lm.app.StartRMI.java
@SuppressWarnings("static-access") public StartRMI(String[] args) { LOG.warn("This main is only for convencience and might be deprectated soon. Consider using {}.", StartLM.class.getName()); Options opts = new Options(); opts.addOption(OptionBuilder.withLongOpt("help").withDescription("Display help message.").create("?")); opts.addOption(OptionBuilder.withLongOpt("port").withArgName("port-number").hasArg().withDescription(String .format("specifies the port on which rmi registry listens (default: %d)", Registry.REGISTRY_PORT)) .create("p")); try {/*from w w w .j a v a 2 s.c o m*/ CommandLine cmd = new ExtendedGnuParser(true).parse(opts, args); if (cmd.hasOption("help")) CliUtils.print_usage_quit(System.err, StartLM.class.getSimpleName(), opts, USAGE_HEADER, null, 0); _port = Integer.parseInt(cmd.getOptionValue("port", String.valueOf(Registry.REGISTRY_PORT))); } catch (Exception e) { LOG.error("{}: {}", e.getClass().getSimpleName(), e.getMessage()); CliUtils.print_usage_quit(System.err, StartLM.class.getSimpleName(), opts, USAGE_HEADER, String.format("%s: %s%n", e.getClass().getSimpleName(), e.getMessage()), 1); } }
From source file:com.nagarro.core.resolver.RestHandlerExceptionResolver.java
@Override protected ModelAndView doResolveException(final HttpServletRequest request, final HttpServletResponse response, final Object handler, final Exception ex) { if (statusCodeMappings.containsKey(ex.getClass().getSimpleName())) { response.setStatus(statusCodeMappings.get(ex.getClass().getSimpleName()).intValue()); } else {//from w w w . ja v a2 s. co m response.setStatus(DEFAULT_STATUS_CODE); } logger.warn( "Translating exception [" + ex.getClass().getName() + "]: " + YSanitizer.sanitize(ex.getMessage())); logger.error(ExceptionUtils.getStackTrace(ex)); final List<ErrorWsDTO> errorList; if (ex instanceof WebserviceValidationException) { errorList = getWebserviceErrorFactory() .createErrorList(((WebserviceValidationException) ex).getValidationObject()); } else { errorList = getWebserviceErrorFactory().createErrorList(ex); } final ErrorListWsDTO errorListDto = new ErrorListWsDTO(); errorListDto.setErrors(errorList); final ServletServerHttpRequest inputMessage = new ServletServerHttpRequest(request); final ServletServerHttpResponse outputMessage = new ServletServerHttpResponse(response); try { return writeWithMessageConverters(errorListDto, inputMessage, outputMessage); } catch (final Exception handlerException) { logger.error("Handling of [" + ex.getClass().getName() + "] resulted in Exception", handlerException); } return null; }