List of usage examples for java.lang Exception getCause
public synchronized Throwable getCause()
From source file:com.nandhootoo.services.UserServiceImpl.java
public void deleteKey(Integer id) { try {/*from w w w.j a v a 2s. c o m*/ String hqlDelete = "delete User where id = :idString "; int deletedEntries = entityManager.createQuery(hqlDelete).setParameter("idString", id).executeUpdate(); } catch (Exception ex) { throw (RuntimeException) ex.getCause(); } }
From source file:org.floggy.synchronization.jme.server.SynchronizationServletTest.java
/** * DOCUMENT ME!// w w w .j a va2s.c o m */ @Test public void testDoGetServletRequestServletResponseException() { MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletResponse response = new MockHttpServletResponse(); SynchronizationServlet servlet = new SynchronizationServlet(); try { request.setContent(getContent(Person.class)); servlet.doGet(request, response); } catch (Exception e) { Assert.assertEquals(e.getCause().getClass(), SynchronizationException.class); } }
From source file:it.cnr.icar.eric.server.persistence.PersistenceManagerFactory.java
public PersistenceManager getPersistenceManager() { if (pm == null) { synchronized (this) { if (pm == null) { try { String pluginClass = RegistryProperties.getInstance() .getProperty(PERSISTENCE_MANAGER_CLASS_PROPERTY); pm = (PersistenceManager) createPluginInstance(pluginClass); } catch (Exception e) { Throwable cause = e.getCause(); e.printStackTrace(); if (cause != null) { System.err.println("Caused by....."); cause.printStackTrace(); }/*from w ww . j ava2s . c om*/ String errmsg = "[PersistenceManager] Cannot instantiate " + "PersistenceManager plugin. Please check that " + "property '" + PERSISTENCE_MANAGER_CLASS_PROPERTY + "' is correctly set in eric.properties file."; System.err.println(errmsg); } } } } return pm; }
From source file:org.osgp.adapter.protocol.dlms.exceptions.OsgpExceptionConverter.java
/** * If the Exception is a OsgpException, this exception is returned. * * If the Exception is not an OsgpException, only the exception message will * be wrapped in an TechnicalException (OsgpException subclass) and * returned. This also applies to the cause when it is an OsgpException. * * @param e//from w w w . j a v a 2 s. c o m * The exception. * @return OsgpException the given exception or a new TechnicalException * instance. */ public OsgpException ensureOsgpOrTechnicalException(final Exception e) { if (e instanceof OsgpException) { final Throwable cause = e.getCause(); if (cause != null && !(cause instanceof OsgpException)) { return new OsgpException(ComponentType.PROTOCOL_DLMS, e.getMessage(), new OsgpException(ComponentType.PROTOCOL_DLMS, cause.getMessage())); } return (OsgpException) e; } return new TechnicalException(ComponentType.PROTOCOL_DLMS, "Unexpected exception while handling protocol request/response message", new OsgpException(ComponentType.PROTOCOL_DLMS, e.getMessage())); }
From source file:br.com.sicoob.cro.cop.batch.core.launcher.LauncherExecutor.java
/** * Executa o processamento.//from w ww .j a va 2s . com * * @return TRUE - para compilacao. * @throws java.lang.Exception par algum erro. */ public Boolean call() throws Exception { LOG.info(BatchPropertiesUtil.getInstance().getMessage(BatchKeys.BATCH_LAUNCHER_INITIALIZING.getKey())); try { setProperty(this.execution, BatchKeys.STATUS.getKey(), Status.STARTED); executeJob(); setProperty(this.execution, BatchKeys.RESULT.getKey(), Result.SUCCESS); LOG.info(BatchPropertiesUtil.getInstance().getMessage(BatchKeys.BATCH_LAUNCHER_ENDING.getKey())); } catch (Exception excecao) { LOG.fatal(Validation.getOr(excecao.getCause(), excecao).getMessage(), excecao); LOG.info(BatchPropertiesUtil.getInstance().getMessage(BatchKeys.BATCH_LAUNCHER_ERROR_ENDING.getKey())); setProperty(this.execution, BatchKeys.RUNNING_JOB.getKey(), null); setProperty(this.execution, BatchKeys.RESULT.getKey(), Result.FAIL); MethodUtils.invokeMethod(this.execution, BatchKeys.ADD_ERROR_MESSAGE.getKey(), excecao); } finally { setProperty(this.execution, BatchKeys.STATUS.getKey(), Status.COMPLETED); } return Boolean.TRUE; }
From source file:org.jahia.services.usermanager.ldap.communication.BaseLdapActionCallback.java
@Override public T onError(Exception e) { final Throwable cause = e.getCause(); logger.error("An error occurred while communicating with the LDAP server", e); if (cause instanceof CommunicationException || cause instanceof ServiceUnavailableException || cause instanceof InsufficientResourcesException) { externalUserGroupService.setMountStatus(key, JCRMountPointNode.MountStatus.waiting); }//from w w w . j a v a 2 s. c o m return null; }
From source file:com.alibaba.event.AbstractEventListener.java
/** * /*from w ww . j a v a 2 s .co m*/ * * @param eventContext */ public void response(EventContext eventContext) throws EventException { if (eventContext == null) { return; } String triggerEventName = eventContext.getEventName(); if (StringUtils.isBlank(triggerEventName)) { return; } EventDTO eventDTO = eventContext.getEventDTO(); for (EventModel eventModel : eventList) { try { String eventName = eventModel.getEventName(); if (triggerEventName.equals(eventName)) { IEventCallBack eventCallBack = eventModel.getEventCallBack(); if (eventCallBack == null) { throw new EventException( String.format("can't get call back for event=%s", triggerEventName)); } else { /*************************************************** * ***************************************************/ eventCallBack.execute(eventDTO); break; } } } catch (Exception e) { throw new EventException(e.getMessage(), e.getCause()); } } }
From source file:com.legstar.xsd.def.Xsd2CobMainTest.java
/** * Test with bad input URI.//from w ww . j a v a 2s. c o m */ public void testWrongInputArgument() { try { _main.execute(new String[] { "" }); fail(); } catch (Exception e) { assertTrue(e.getCause().getMessage().contains("java.io.FileNotFoundException")); } try { _main.execute(new String[] { "-i", "c:\\noaURI" }); fail(); } catch (Exception e) { assertEquals("Illegal character in opaque part at index 2: c:\\noaURI", e.getCause().getMessage()); } }
From source file:com.sematext.ag.player.SimplePlayer.java
protected void play(Sink<Event> sink, Source source) { Event e = source.nextEvent(); while (null != e) { try {//from w w w. j a v a 2 s . c o m sink.startCounters(); sink.write(e); sink.endCounters(); } catch (Exception ex) { LOG.error("Error writing to sink, skipping event. Cause: " + ex.getCause()); } e = source.nextEvent(); } }
From source file:co.turnus.trace.example.SimpleTraceExample.java
public TraceProject loadProject() { TurnusLogger.info("Load the causation trace"); try {// w ww .j a v a 2 s . c o m File dir = new File(SimpleTraceExample.class.getResource("/co/turnus/trace/example/").toURI()); TraceProject project = TraceProject.load(dir); Configuration config = new BaseConfiguration(); config.setProperty(SENS_STATEVAR, false); project.loadTrace(config); trace = project.getTrace(); decorator = project.getTraceDecorator(); return project; } catch (Exception e) { throw new TurnusRuntimeException("Error loading the trace file", e.getCause()); } }