List of usage examples for java.lang Throwable getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:com.dianping.swallow.broker.monitor.DefaultNotifyService.java
@Override public void alarm(String msg, Throwable t, boolean sendSms) { log.error(MAIL_ALARM_TITLE + " : " + msg, t); if (!devMode) { StringBuilder body = new StringBuilder(); body.append("<strong>").append(msg).append("</strong><br/>"); body.append("<br/>"); if (t != null) { body.append("<b>").append("Exception message:").append(" </b>").append(t.getClass().getName()) .append(":").append(t.getMessage()).append("<br/>"); body.append("<i>").append("Stack trace:").append(" <i><br/>"); body.append(displayErrorForHtml(t)); }/*from w w w .jav a 2 s .co m*/ try { this.alarmService.sendEmail(body.toString(), MAIL_ALARM_TITLE + "_" + localIP, getMailTos()); if (sendSms) { List<String> numbers = getPhoneNums(); if (numbers != null && numbers.size() > 0) { this.alarmService.sendSmsMessage( "[swallow-broker Alarm]" + "_" + localIP + ":" + StringUtils.abbreviate(msg, 1000), numbers); } } } catch (Exception e) { log.warn("Alarm failed. BODY: " + body); } } }
From source file:jp.co.opentone.bsol.linkbinder.view.exception.LinkBinderExceptionHandler.java
FacesMessage createFatalMessage(Throwable e) { if (e.getCause() == null) { FacesMessage m = new FacesMessage(); m.setSeverity(FacesMessage.SEVERITY_FATAL); m.setSummary(m.getSeverity().toString()); m.setDetail(String.format("Unhandled exception : %s", e.getClass().getSimpleName())); return m; } else {/*from ww w . j a v a2 s.co m*/ return createFatalMessage(e.getCause()); } }
From source file:com.alliander.osgp.acceptancetests.firmwaremanagement.GetFirmwareVersionSteps.java
@DomainStep("the get firmware version response request should return a firmware response with result (.*), description (.*) and firmwareversion (.*)") public boolean thenTheGetFirmwareVersionResponseRequestShouldReturnAGetFirmwareVersionResponse( final String result, final String description, final String firmwareversion) { LOGGER.info(/*from w w w . ja v a2 s .c o m*/ "THEN: \"the get firmware response request should return a firmware response with result {}, description {} and firmwareversion {}", result, description, firmwareversion); try { if ("NOT_OK".equals(result)) { Assert.assertNull("Set Schedule Response should be null", this.response); Assert.assertNotNull("Throwable should not be null", this.throwable); Assert.assertTrue("Throwable should contain a validation exception", this.throwable.getCause() instanceof ValidationException); } else { Assert.assertNotNull("Response should not be null", this.response); final String expected = result.equals("NULL") ? null : result; final String actual = this.response.getResult().toString(); Assert.assertTrue("Invalid result, found: " + actual + " , expected: " + expected, (actual == null && expected == null) || actual.equals(expected)); if ("OK".equals(result)) { Assert.assertEquals(this.response.getFirmwareVersion().get(0).getVersion(), firmwareversion); } } } catch (final Throwable t) { LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage()); return false; } return true; }
From source file:com.alliander.osgp.acceptancetests.adhocmanagement.SetTransitionSteps.java
@DomainStep("the get set transition response request should return a set transition response with result (.*) and description (.*)") public boolean thenTheGetSetTransitionResultRequestShouldReturnAGetSetTransitionResultResponseWithResult( final String result, final String description) { LOGGER.info(//from w w w .j av a2 s . com "THEN: \"the get set transition result request should return a get set transition response with result {} and description {}", result, description); try { if ("NOT_OK".equals(result)) { Assert.assertNull("Set Schedule Response should be null", this.response); Assert.assertNotNull("Throwable should not be null", this.throwable); Assert.assertTrue("Throwable should contain a validation exception", this.throwable.getCause() instanceof ValidationException); } else { Assert.assertNotNull("Response should not be null", this.response); final String expectedResult = result.equals("NULL") ? null : result; final String actualResult = this.response.getResult().toString(); Assert.assertTrue("Invalid result, found: " + actualResult + " , expected: " + expectedResult, (actualResult == null && expectedResult == null) || actualResult.equals(expectedResult)); } } catch (final Throwable t) { LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage()); return false; } return true; }
From source file:com.aol.advertising.qiao.injector.file.AbstractFileReader.java
private void abortTransactiolnSliently() { try {/*from w ww . j a v a 2 s. c o m*/ readPosition.abortTransaction(); } catch (Throwable t) { if (logger.isDebugEnabled()) logger.debug("abortTransaction>" + t.getClass().getSimpleName() + ":" + t.getMessage()); } }
From source file:net.pms.network.RequestHandlerV2.java
@Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { Channel ch = e.getChannel();/* ww w. j a v a 2 s . c o m*/ Throwable cause = e.getCause(); if (cause instanceof TooLongFrameException) { sendError(ctx, HttpResponseStatus.BAD_REQUEST); return; } if (cause != null) { if (cause.getClass().equals(IOException.class)) { LOGGER.debug("Connection error: " + cause); StartStopListenerDelegate startStopListenerDelegate = (StartStopListenerDelegate) ctx .getAttachment(); if (startStopListenerDelegate != null) { LOGGER.debug("Premature end, stopping..."); startStopListenerDelegate.stop(); } } else if (!cause.getClass().equals(ClosedChannelException.class)) { LOGGER.debug("Caught exception: {}", cause.getMessage()); LOGGER.trace("", cause); } } if (ch.isConnected()) { sendError(ctx, HttpResponseStatus.INTERNAL_SERVER_ERROR); } ch.close(); }
From source file:de.decoit.visa.http.ajax.handlers.ConfigureHandler.java
@Override public void handle(HttpExchange he) throws IOException { log.info(he.getRequestURI().toString()); // Get the URI of the request and extract the query string from it QueryString queryParameters = new QueryString(he.getRequestURI()); // Create StringBuilder for the response String response = null;//from w ww . j a va 2s . co m // Check if the query parameters are valid for this handler if (this.checkQueryParameters(queryParameters)) { try { // Close any existing connection to IO-Tool, this handler is // called on reload of the frontend try { TEBackend.closeIOConnector(false); } catch (IOToolException iote) { log.warn("Cannot close connection to the IO-Tool, using connection from old session"); } // Process document root parameter String docRoot = queryParameters.get("documentRoot").get(); // Set export directory StringBuilder sbExportPath = new StringBuilder(docRoot); if (!docRoot.endsWith("/")) { sbExportPath.append("/"); } sbExportPath.append("export/"); TEBackend.setExportPath(sbExportPath.toString()); // Set import directory StringBuilder sbImportPath = new StringBuilder(docRoot); if (!docRoot.endsWith("/")) { sbImportPath.append("/"); } sbImportPath.append("import/"); TEBackend.setImportPath(sbImportPath.toString()); // Process rows and cols parameter int rows = Integer.parseInt(queryParameters.get("rows").get()); int cols = Integer.parseInt(queryParameters.get("cols").get()); TEBackend.setGridDimensions(cols, rows); TEBackend.TOPOLOGY_STORAGE.getComponentGroupByName("0.0.0.0").setSubgridDimensions(cols, rows); // Process cell size parameter int cSize = Integer.parseInt(queryParameters.get("csize").get()); TEBackend.setCellSize(cSize); // Process component margin parameter int compMargin = Integer.parseInt(queryParameters.get("compMargin").get()); TEBackend.setComponentMargin(compMargin); // Return success response JSONObject rv = new JSONObject(); rv.put("status", AJAXServer.AJAX_SUCCESS); rv.put("vsatemplates", TEBackend.RDF_MANAGER.vsaTemplatesToJSON()); response = rv.toString(); } catch (Throwable ex) { TEBackend.logException(ex, log); // Exception was thrown during configuration JSONObject rv = new JSONObject(); try { rv.put("status", AJAXServer.AJAX_ERROR_EXCEPTION); rv.put("type", ex.getClass().getSimpleName()); rv.put("message", ex.getMessage()); } catch (JSONException exc) { /* Ignore */ } response = rv.toString(); } } else { // Missing or malformed query string, set response to error code JSONObject rv = new JSONObject(); try { // Missing or malformed query string, set response to error code rv.put("status", AJAXServer.AJAX_ERROR_MISSING_ARGS); } catch (JSONException exc) { /* Ignore */ } response = rv.toString(); } // Send the response sendResponse(he, response); }
From source file:de.hybris.platform.atddimpex.keywords.ImpexKeywordLibrary.java
private void importImpExFromInputStream(final String resourceName, final InputStream inputStream, final String expectedException) throws IOException { Throwable exception = null; try {/*from w w w . j av a2 s . c o m*/ importImpExFromInputStream(resourceName, inputStream); } catch (final Exception e) { exception = e; while (exception.getCause() != null) { exception = exception.getCause(); } if (exception.getClass().getSimpleName().equals(expectedException)) { LOG.info("Expected [" + expectedException + "] caught: " + exception.getMessage()); } else { LOG.error(exception.getMessage(), exception); } } finally { IOUtils.closeQuietly(inputStream); } if (expectedException == null) { assertNull("Import of resource " + resourceName + " failed: " + (exception == null ? "" : exception.getMessage()), exception); } else { assertNotNull("Expected [" + expectedException + "] not thrown", exception); assertEquals("Type of thrown exception does not match type of expected exception", expectedException, exception.getClass().getSimpleName()); } }
From source file:com.alliander.osgp.acceptancetests.schedulemanagement.SetTariffScheduleSteps.java
@DomainStep("the set tariff schedule request is received") public void whenTheSetTariffScheduleRequestIsReceived() { LOGGER.info("WHEN: \"the set tariff schedule request is received\"."); try {//from w w w . ja v a2s .co m this.setScheduleAsyncResponse = this.scheduleManagementEndpoint.setSchedule(ORGANISATION_ID, this.request); } catch (final Throwable t) { LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage()); this.throwable = t; } }
From source file:com.alliander.osgp.acceptancetests.schedulemanagement.SetTariffScheduleSteps.java
@DomainStep("the get set tariff schedule response request is received") public void whenTheGetSetTariffScheduleResultReqeustIsReceived() { LOGGER.info("WHEN: \"the set tariff schedule request is received\"."); try {/*from w ww. j a v a 2 s. c om*/ this.response = this.scheduleManagementEndpoint.getSetScheduleResponse(ORGANISATION_ID, this.setTariffScheduleAsyncRequest); } catch (final Throwable t) { LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage()); this.throwable = t; } }