List of usage examples for java.lang Throwable getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:de.decoit.visa.http.ajax.handlers.RequestTopologyHandler.java
@Override public void handle(HttpExchange he) throws IOException { log.info(he.getRequestURI().toString()); String response;/*from w w w. j a va2s. com*/ try { JSONObject rv = new JSONObject(); rv.put("status", AJAXServer.AJAX_SUCCESS); rv.put("topology", TEBackend.TOPOLOGY_STORAGE.genTopologyJSON()); response = rv.toString(); } catch (Throwable ex) { TEBackend.logException(ex, log); 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(); } // Send the response headers sendResponse(he, response); }
From source file:com.greplin.gec.GecAppender.java
/** * Writes a formatted exception to the given writer. * * @param message the log message//from w w w.j a v a 2 s. co m * @param throwable the exception * @param out the destination * @throws IOException if there are IO errors in the destination */ void writeFormattedException(final String message, final Throwable throwable, final Writer out) throws IOException { JsonGenerator generator = new JsonFactory().createJsonGenerator(out); Throwable rootThrowable = throwable; while (passthroughExceptions.contains(rootThrowable.getClass()) && rootThrowable.getCause() != null) { rootThrowable = rootThrowable.getCause(); } generator.writeStartObject(); generator.writeStringField("project", project); generator.writeStringField("environment", environment); generator.writeStringField("serverName", serverName); generator.writeStringField("backtrace", ExceptionUtils.getStackTrace(throwable)); generator.writeStringField("message", rootThrowable.getMessage()); generator.writeStringField("logMessage", message); generator.writeStringField("type", rootThrowable.getClass().getName()); writeContext(generator); generator.writeEndObject(); generator.close(); }
From source file:com.alliander.osgp.acceptancetests.devicemanagement.UpdateKeySteps.java
@DomainStep("the update key request is received on OSGP") public void whenTheUpdateKeyRequestIsReceivedOnOSGP() { LOGGER.info("WHEN: \"the update key request is received on OSGP\"."); try {/*w w w .java 2s . co m*/ this.response = this.deviceManagementEndpoint.updateKey(ORGANISATION_ID, this.request); } catch (final Throwable t) { LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage()); this.throwable = t; } }
From source file:com.haulmont.cuba.web.log.AppLog.java
@SuppressWarnings("ThrowableResultOfMethodCallIgnored") public void log(ErrorEvent event) { Throwable t = event.getThrowable(); if (t instanceof SilentException) return;/*from w ww.j a v a 2 s . c o m*/ if (t instanceof Validator.InvalidValueException) return; if (t instanceof SocketException || ExceptionUtils.getRootCause(t) instanceof SocketException) { // Most likely client browser closed socket LogItem item = new LogItem(LogLevel.WARNING, "SocketException in CommunicationManager. Most likely client (browser) closed socket.", null); log(item); return; } // Support Tomcat 8 ClientAbortException if (StringUtils.contains(ExceptionUtils.getMessage(t), "ClientAbortException")) { // Most likely client browser closed socket LogItem item = new LogItem(LogLevel.WARNING, "ClientAbortException on write response to client. Most likely client (browser) closed socket.", null); log(item); return; } Throwable rootCause = ExceptionUtils.getRootCause(t); if (rootCause == null) rootCause = t; Logging annotation = rootCause.getClass().getAnnotation(Logging.class); Logging.Type loggingType = annotation == null ? Logging.Type.FULL : annotation.value(); if (loggingType == Logging.Type.NONE) return; // Finds the original source of the error/exception AbstractComponent component = DefaultErrorHandler.findAbstractComponent(event); StringBuilder msg = new StringBuilder(); msg.append("Exception"); if (component != null) msg.append(" in ").append(component.getClass().getName()); msg.append(": "); if (loggingType == Logging.Type.BRIEF) { error(msg + rootCause.toString()); } else { LogItem item = new LogItem(LogLevel.ERROR, msg.toString(), t); log(item); } }
From source file:com.alliander.osgp.acceptancetests.devicemanagement.UpdateKeySteps.java
@DomainStep("an update key response should be returned") public boolean thenAnUpdateKeyResponseShouldBeReturned() { try {/*from ww w .j a v a 2s. com*/ Assert.assertNotNull("Response should not be null", this.response); Assert.assertNull("Throwable should be null", this.throwable); } catch (final Throwable t) { LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage()); return false; } return true; }
From source file:com.alliander.osgp.acceptancetests.devicemanagement.UpdateKeySteps.java
@DomainStep("the update key request should return an error message") public boolean thenTheRequestShouldReturnAnError() { try {/*from w ww . ja va 2 s .com*/ Assert.assertNull("Response should be null", this.response); Assert.assertNotNull("Throwable should not be null", this.throwable); } catch (final Throwable t) { LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage()); return false; } return true; }
From source file:com.reversemind.hypergate.integration.ejb.client.AbstractClientEJB.java
@Override public <T> T getProxy(Class<T> interfaceClass) throws Exception { if (clientPool == null) { this.clientFullReconnect(); if (clientPool == null) { throw new Exception("HyperGate client is not running"); }/*from ww w. j a v a2s.c om*/ } if (this.proxyFactoryPool == null) { this.clientFullReconnect(); if (this.proxyFactoryPool == null) { throw new Exception("Could not get proxyFactory for " + interfaceClass); } } T object = null; try { LOG.info("Going to create new newProxyInstance from proxyFactory" + this.proxyFactoryPool); LOG.info("Client pool is:" + clientPool); //object = (T)this.proxyFactory.newProxyInstance(interfaceClass); object = (T) this.proxyFactoryPool.newProxyInstance(this.clientPool, interfaceClass); } catch (Throwable th) { // com.reversemind.hypergate.proxy.ProxySendException: =HyperGate= Could not to send data into server: - let's reconnect Throwable throwableLocal = th.getCause(); LOG.warn("some troubles with sending data to the server let's reconnect"); if (throwableLocal.getClass().equals(ProxySendException.class)) { LOG.info("detected ProxySendException:" + throwableLocal.getMessage()); this.clientFullReconnect(); //object = (T)this.proxyFactory.newProxyInstance(interfaceClass); LOG.info("Client pool is:" + clientPool); object = (T) this.proxyFactoryPool.newProxyInstance(this.clientPool, interfaceClass); } if (throwableLocal.getCause().getClass().equals(Exception.class)) { throw new Exception("Could not to get proxy or send data to server"); } } return object; }
From source file:com.alliander.osgp.acceptancetests.devicemanagement.UpdateKeySteps.java
@DomainStep("the device (.*) should not be updated with the invalid key (.*)") public boolean thenTheDeviceShouldBeUpdatedWithTheInvalidKey(final String device, final String key) { LOGGER.info("THEN: \"the device {} should not be updated with the invalid key {}\".", device, key); try {//from w w w . ja v a2 s. c o m verify(this.oslpDeviceRepositoryMock, timeout(10000).times(0)).save(any(OslpDevice.class)); } catch (final Throwable t) { LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage()); return false; } return true; }
From source file:fr.duminy.components.swing.listpanel.SimpleItemManagerTest.java
private void addCallback(ListenableFuture<Bean> futureBean, final String operation) { Futures.addCallback(futureBean, new FutureCallback<Bean>() { @Override//from w w w . j a v a 2 s . c o m public void onSuccess(Bean result) { setBean(result); LOG.info(operation + ": set bean to {}", result); } @Override public void onFailure(Throwable t) { if (CancellationException.class.isAssignableFrom(t.getClass())) { LOG.error(operation + " operation has been cancelled => set bean to null"); setBean(null); } else { LOG.error("Can't " + operation + " item => set bean to ErrorBean", t); setBean(ERROR_BEAN); } } }); }
From source file:com.telefonica.euro_iaas.paasmanager.manager.async.impl.VirtualServiceAsyncManagerImpl.java
private void updateErrorTask(Task task, String message, Throwable t) { TaskError error = new TaskError(message); error.setMajorErrorCode(t.getMessage()); error.setMinorErrorCode(t.getClass().getSimpleName()); task.setEndTime(new Date()); task.setStatus(TaskStates.ERROR);// w w w. jav a 2 s .c o m task.setError(error); taskManager.updateTask(task); log.info("An error occurs while installing Virtual Service. See task " + task.getHref() + " for more information"); }