List of usage examples for java.lang Exception getCause
public synchronized Throwable getCause()
From source file:Main.java
/** * Validates a XPath expression./*from w w w . jav a 2s. c o m*/ * @param xpathExpression the XPath expression to validate * @return null if the expression is correct, an error message otherwise */ public static String validateXPathExpression(String xpathExpression) { String msg = null; try { X_PATH.compile(xpathExpression); } catch (Exception e) { String cause = null; if (e.getCause() != null) e.getCause().getMessage(); else cause = e.getMessage(); cause = cause == null ? "" : " " + cause; msg = "Invalid XPath expression." + cause; } return msg; }
From source file:beyondlambdas.slides.s8_1.Support.java
public static void trackError(final Exception e) { System.out.println("ERROR: Problem parsing user: " + e.getCause().getCause().getMessage()); }
From source file:myproject.Model.Common.ProcessExecutor.java
private static String properExecuteQuitely(File file, String... commands) { try {/*from w w w .j a v a 2s .c om*/ properExecute(file, commands); } catch (Exception ex) { ex.printStackTrace(); Log.errorLog(ex, ex.getCause(), ProcessExecutor.class); } return null; }
From source file:org.kegbot.app.setup.SetupFragment.java
protected static String toHumanError(Exception e) { StringBuilder builder = new StringBuilder(); if (e.getCause() instanceof HttpHostConnectException) { builder.append("Could not connect to remote host."); } else if (e instanceof NotAuthorizedException) { builder.append("Username or password was incorrect."); } else if (e instanceof KegbotApiServerError) { builder.append("Bad response from server ("); builder.append(e.toString());//from ww w. j a va2 s . co m builder.append(")"); } else if (e instanceof SocketException || e.getCause() instanceof SocketException) { builder.append("Server is down or unreachable."); } else { builder.append(e.getMessage()); } return builder.toString(); }
From source file:com.github.weikengc.spring.jpdl.config.JpdlNamespaceHandlerTest.java
private static <T extends Exception> Matcher cause(Matcher<T> causeMatcher) { return new FeatureMatcher<Exception, T>(causeMatcher, "cause", "cause") { @Override// w ww . j a va 2s. c o m protected T featureValueOf(Exception ex) { return (T) ex.getCause(); } }; }
From source file:org.jboss.aerogear.sync.jsonmergepatch.client.JsonMergePatchClientSynchronizer.java
public static String checksum(final JsonNode content) { try {//w w w.j a v a 2s.c om final MessageDigest md = MessageDigest.getInstance("SHA1"); md.update(content.asText().getBytes(UTF_8)); return new BigInteger(1, md.digest()).toString(16); } catch (final Exception e) { throw new RuntimeException(e.getMessage(), e.getCause()); } }
From source file:Main.java
private static String getExceptionDescription(Exception exception) { return exception != null ? exception.getLocalizedMessage() + "\n" + exception.getMessage() + "\ncause: " + exception.getCause() : "No description"; }
From source file:com.hazelcast.qasonar.utils.PropertyReaderBuilder.java
private static PropertyReader fromProperties(Properties props) { try {/*from w ww. j a v a 2 s . com*/ PropertyReader propertyReader = new PropertyReader(getProperty(props, "host"), getProperty(props, "username"), getProperty(props, "password")); addProjectResourceIds(propertyReader, getProperty(props, "projectResourceIds")); propertyReader.setLocalGitRoot(getProperty(props, "localGitRoot")); propertyReader.setGitHubRepository(getProperty(props, "gitHubRepository")); String minCodeCoverageString = getProperty(props, "minCodeCoverage"); double minCodeCoverage = (minCodeCoverageString == null) ? DEFAULT_MIN_CODE_COVERAGE : valueOf(minCodeCoverageString); propertyReader.setMinCodeCoverage(minCodeCoverage, false); String minCodeCoverageModifiedString = props.getProperty("minCodeCoverageModified"); if (minCodeCoverageModifiedString != null) { propertyReader.setMinCodeCoverage(valueOf(minCodeCoverageModifiedString), true); } return propertyReader; } catch (Exception e) { throw new IllegalStateException("Could not read property file!", e.getCause()); } }
From source file:com.github.ibole.infrastructure.common.exception.MoreThrowables.java
/** * ??./* w ww .j av a 2 s .c om*/ */ @SuppressWarnings("unchecked") public static boolean isCausedBy(Exception ex, Class<? extends Exception>... causeExceptionClasses) { Throwable cause = ex.getCause(); while (cause != null) { for (Class<? extends Exception> causeClass : causeExceptionClasses) { if (causeClass.isInstance(cause)) { return true; } } cause = cause.getCause(); } return false; }
From source file:info.magnolia.cms.util.AlertUtil.java
/** * Creates a string message out of an exception. Handles nested exceptions. * @param e//from w ww. j ava 2 s .co m * @return the message */ public static String getExceptionMessage(Exception e) { String message = e.getMessage(); if (StringUtils.isEmpty(message)) { if (e.getCause() != null) { message = e.getCause().getMessage(); } if (message == null) { message = StringUtils.EMPTY; } } return message; }