List of usage examples for java.lang Exception getCause
public synchronized Throwable getCause()
From source file:com.sisrni.managedbean.MenusAdmMB.java
public void cancelar() throws Exception { try {/* w w w. j a v a2 s . c o m*/ this.ssMenus = null; RequestContext.getCurrentInstance().update(":formAdmin"); RequestContext.getCurrentInstance().update(":formMenu"); } catch (Exception e) { e.printStackTrace(); throw new Exception("Error class MenusOpcionesMB - Editar()\n" + e.getMessage(), e.getCause()); } finally { this.ssMenus = new SsMenus(); } }
From source file:com.mercatis.lighthouse3.persistence.commons.rest.DomainModelEntityDAOImplementation.java
/** * This method performs an HTTP request against the RESTful web service. * /* w ww .j a va 2 s . c om*/ * @param resourcePath * the path to the resource relative to the server url. * @param method * the HTTP method to execute * @param body * the body of a POST or PUT request, can be <code>null</code> * @param queryParams * a Hash with the query parameter, can be <code>null</code> * @return the data returned by the web service * @throws PersistenceException * in case a communication error occurred. */ protected String executeHttpMethod(String resourcePath, HttpMethod method, String body, Map<String, String> queryParams) { String url = null; try { url = new URI(this.getServerUrl() + resourcePath, true).toString(); } catch (Exception e) { throw new PersistenceException("Invalid resource path given", e); } try { return new HttpRequest(user, password).execute(url, method, body, queryParams); } catch (Exception anyProblem) { String message = anyProblem.getCause() != null ? anyProblem.getCause().getMessage() : anyProblem.getMessage(); throw new PersistenceException(message, anyProblem); } }
From source file:com.sunrun.crportal.util.CRPortalUtil.java
public static int getSRCustomerId(PortletRequest req) throws CRPortletException { if (getSunRunCustomerIdFromSession(req) != null) { return getSunRunCustomerIdFromSession(req).intValue(); }/*from w ww. j a v a 2s .c o m*/ try { return new Integer(UserLocalServiceUtil.getUser(getUserId(req)).getScreenName()).intValue(); } catch (Exception e) { throw new CRPortletException(e.getLocalizedMessage(), e.getCause()); } }
From source file:models.Application.java
/** * Check for any other application that may be present on the port and throw an exception if there is any. *///from w w w . j av a 2s . co m private void checkForOtherApplication(final String url) throws Exception { try { final WSRequest request = WS.url(url); request.timeout("1s"); // set time-out to a low value to make sure // we time-out when there is a connect but // no answer, for example with SSH request.get(); throw new Exception("There is already another application bound to " + url); } catch (Exception e) { // very dirty, but Play! wraps all upper level exceptions, so there really isn't any other way if (e.getCause() != null && e.getCause().getCause() != null && e.getCause().getCause() instanceof ConnectException) { // this is good Logger.info("Port seems to be free"); } else { // this means that there is an application there // there is either a timeout, a HTTP app, or another protocol than HTTP throw new Exception("There is already another application bound to " + url + ": " + e.getMessage()); } } }
From source file:com.sisrni.managedbean.OpcionesAdmMB.java
public void cancelar() throws Exception { try {//from w w w. j a v a2s. c o m this.ssOpciones = null; setActualizar(false); RequestContext.getCurrentInstance().update(":formAdmin"); RequestContext.getCurrentInstance().update(":formMenu"); } catch (Exception e) { e.printStackTrace(); throw new Exception("Error class MenusOpcionesMB - Editar()\n" + e.getMessage(), e.getCause()); } finally { this.ssOpciones = new SsOpciones(); } }
From source file:bridge.toolkit.ControllerJFrame.java
private void RunButtonActionPerformed(java.awt.event.ActionEvent evt) { ctx.put(Keys.SCPM_FILE, SCPMField.getText()); ctx.put(Keys.RESOURCE_PACKAGE, ResourceField.getText()); ctx.put(Keys.OUTPUT_DIRECTORY, OutputDirectoryField.getText()); try {// w ww.ja v a 2 s .c o m if (outputType.equals("-scormflash")) { toolkit = sampleCatalog.getCommand("SCORM"); ctx.put(Keys.OUTPUT_TYPE, null); } else if (outputType.equals("-scormhtml")) { toolkit = sampleCatalog.getCommand("SCORM"); ctx.put(Keys.OUTPUT_TYPE, "SCORMHTML"); } else if (outputType.equals("-mobile")) { toolkit = sampleCatalog.getCommand("Mobile"); } else if (outputType.equals("-mobilecourse")) { toolkit = sampleCatalog.getCommand("Mobile"); ctx.put(Keys.OUTPUT_TYPE, "mobileCourse"); } else if (outputType.equals("-pdfinstructor")) { toolkit = sampleCatalog.getCommand("PDF"); ctx.put(Keys.PDF_OUTPUT_OPTION, "-instructor"); } else if (outputType.equals("-pdfstudent")) { toolkit = sampleCatalog.getCommand("PDF"); ctx.put(Keys.PDF_OUTPUT_OPTION, "-student"); } if (toolkit != null) { toolkit.execute(ctx); } } catch (Exception e) { e.printStackTrace(); System.out.println(e.getCause().toString()); } }
From source file:hoot.services.db.DbUtils.java
public static void clearTable(com.mysema.query.sql.RelationalPathBase<?> t, Connection conn) throws Exception { try {/* w ww .j a va 2s . c om*/ Configuration configuration = getConfiguration(); new SQLDeleteClause(conn, configuration, t).execute(); } catch (Exception e) { log.error(e.getCause().getMessage()); } }
From source file:net.sf.ehcache.exceptionhandler.ExceptionHandlingDynamicCacheProxy.java
/** * Processes a method invocation on a proxy instance and returns * the result. This method will be invoked on an invocation handler * when a method is invoked on a proxy instance that it is * associated with./*from ww w . j ava 2 s .c o m*/ * * @param proxy the proxy instance that the method was invoked on * @param method the <code>Method</code> instance corresponding to * the interface method invoked on the proxy instance. The declaring * class of the <code>Method</code> object will be the interface that * the method was declared in, which may be a superinterface of the * proxy interface that the proxy class inherits the method through. * @param args an array of objects containing the values of the * arguments passed in the method invocation on the proxy instance, * or <code>null</code> if interface method takes no arguments. * Arguments of primitive types are wrapped in instances of the * appropriate primitive wrapper class, such as * <code>java.lang.Integer</code> or <code>java.lang.Boolean</code>. * @return the value to return from the method invocation on the * proxy instance. If the declared return type of the interface * method is a primitive type, then the value returned by * this method must be an instance of the corresponding primitive * wrapper class; otherwise, it must be a type assignable to the * declared return type. If the value returned by this method is * <code>null</code> and the interface method's return type is * primitive, then a <code>NullPointerException</code> will be * thrown by the method invocation on the proxy instance. If the * value returned by this method is otherwise not compatible with * the interface method's declared return type as described above, * a <code>ClassCastException</code> will be thrown by the method * invocation on the proxy instance. * @throws Throwable the exception to throw from the method * invocation on the proxy instance. The exception's type must be * assignable either to any of the exception types declared in the * <code>throws</code> clause of the interface method or to the * unchecked exception types <code>java.lang.RuntimeException</code> * or <code>java.lang.Error</code>. If a checked exception is * thrown by this method that is not assignable to any of the * exception types declared in the <code>throws</code> clause of * the interface method, then an * {@link java.lang.reflect.UndeclaredThrowableException} containing the * exception that was thrown by this method will be thrown by the * method invocation on the proxy instance. * @see java.lang.reflect.UndeclaredThrowableException * */ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { Object invocationResult = null; try { invocationResult = method.invoke(ehcache, args); } catch (Exception e) { CacheExceptionHandler cacheExceptionHandler = ehcache.getCacheExceptionHandler(); if (cacheExceptionHandler != null) { String keyAsString = null; //should be a CacheException Throwable cause = e.getCause(); if (cause != null) { keyAsString = extractKey(cause.getMessage()); } Exception causeAsException = null; try { causeAsException = (Exception) cause; } catch (ClassCastException cce) { //we only handle exceptions, not errors. if (LOG.isDebugEnabled()) { LOG.debug("Underlying cause was not an Exception: " + cce); } } cacheExceptionHandler.onException(ehcache, keyAsString, causeAsException); } else { throw e.getCause(); } } return invocationResult; }
From source file:net.sf.ginp.TestSetupInvalid.java
/** * Test that validation of a bad config against a ginp dtd fails * @throws SetupException/*from w w w . ja v a 2 s .c o m*/ * @throws IOException * @see net.sf.ginp.setup.SetupManager#testValidConfig */ public void testInvalidConfig() { final String CONFIG_FILE = "invalidConfig.xml"; try { service.testValidConfig(this.getClass().getResourceAsStream(File.separator + CONFIG_FILE)); fail("Exception expected!"); } catch (Exception e1) { // unroll the nested Exception and verify diagnostics assertTrue("SetupException expected: " + e1, e1 instanceof SetupException); String reason = e1.getMessage(); assertTrue(reason.indexOf("Trouble parsing document") > -1); Throwable e2 = e1.getCause(); assertNotNull(e2); assertTrue(e2 instanceof DocumentException); String reason2 = e2.getMessage(); assertTrue(reason2.indexOf("Element type \"foo\" must be declared") > -1); // Sadly, SetupManagerImpl has no idea where we got the bad // file from, so the Exception misleadingly reports the path // to the DTD, which is probably fine. //assertTrue(reason2.indexOf(CONFIG_FILE)>-1); } }
From source file:com.sisrni.managedbean.MenusAdmMB.java
/** * */*www . ja va2 s . c om*/ * * @param country * @throws Exception */ public void preEditar(SsMenus ssMenus) throws Exception { try { int i = 0; this.ssMenus = ssMenus; selectedArrayRoles = new String[ssMenus.getSsRolesList().size()]; listRolesTemp = ssMenus.getSsRolesList(); for (SsRoles mn : ssMenus.getSsRolesList()) { selectedArrayRoles[i] = mn.getIdRol().toString(); i++; } } catch (Exception e) { e.printStackTrace(); throw new Exception("Error class MenusOpcionesMB - preEditar()\n" + e.getMessage(), e.getCause()); } finally { } }