List of usage examples for java.lang Exception getCause
public synchronized Throwable getCause()
From source file:com.streamsets.pipeline.stage.destination.mqtt.MqttClientTarget.java
private static StageException throwStageException(Exception e) { if (e instanceof RuntimeException) { Throwable cause = e.getCause(); if (cause != null) { return new StageException(Errors.MQTT_01, cause, cause); }/* w ww . j a va2 s .c o m*/ } else if (e instanceof StageException) { return (StageException) e; } return new StageException(Errors.MQTT_01, e, e); }
From source file:io.cloudslang.content.database.utils.SQLUtils.java
public static void loadClassForName(@NotNull final String className) { try {/* w w w .j a v a 2 s . c o m*/ Class.forName(className); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e.getCause()); } }
From source file:com.pinterest.pinlater.backends.mysql.MySQLBackendUtils.java
public static boolean isDeadlockException(Exception e) { return e instanceof MySQLTransactionRollbackException || (e instanceof BatchUpdateException && e.getCause() instanceof MySQLTransactionRollbackException); }
From source file:io.cloudslang.content.database.utils.SQLInputsUtils.java
@NotNull public static SqlDatabase getDbClassForType(@NotNull final String dbType) { try {/*w w w.j a va 2 s. co m*/ return dbTypesClass.get(dbType).newInstance(); } catch (Exception e) { throw new RuntimeException(INVALID_DB_TYPE, e.getCause()); } }
From source file:com.streamsets.pipeline.stage.destination.hbase.HBaseTarget.java
private static StageException throwStageException(Exception e) { if (e instanceof RuntimeException) { Throwable cause = e.getCause(); if (cause != null) { return new StageException(Errors.HBASE_26, cause, cause); }/*w ww.j ava2 s . co m*/ } return new StageException(Errors.HBASE_26, e, e); }
From source file:eu.delving.sip.Harvester.java
static String exceptionToErrorString(Exception exception) { StringBuilder out = new StringBuilder(); out.append(exception.getMessage());// ww w . j av a 2s . c o m Throwable cause = exception.getCause(); while (cause != null) { out.append('\n'); out.append(cause.toString()); cause = cause.getCause(); } return out.toString(); }
From source file:msi.gama.util.file.GamaFileMetaData.java
public static <T extends IGamaFileMetaData> T from(final String s, final long stamp, final Class<T> clazz, final boolean includeOutdated) { T result = null;//from ww w. ja v a 2 s. c om try { final Constructor<T> c = clazz.getDeclaredConstructor(String.class); result = c.newInstance(s); final boolean hasFailed = result.hasFailed(); if (!hasFailed && !includeOutdated && result.getModificationStamp() != stamp) { return null; } } catch (final Exception ignore) { DEBUG.ERR("Error loading metadata " + s + " : " + ignore.getClass().getSimpleName() + ":" + ignore.getMessage()); if (ignore instanceof InvocationTargetException && ignore.getCause() != null) { ignore.getCause().printStackTrace(); } } return result; }
From source file:es.eucm.rage.realtime.TracesAreBubbledUpwardsTheTreeToParent_And_LeafAnalysis_GLPTopologyKafkaElasticTest.java
static void runProducer(final Map trace) { try {//from ww w .ja v a 2 s . c o m String msg = gson.toJson(trace, Map.class); String index = "test"; final ProducerRecord<String, String> record = new ProducerRecord<>(TOPIC, index, msg); producer.send(record).get(); } catch (Exception e) { assertTrue("Error sending to Kafka " + e.getMessage() + " cause " + e.getCause(), false); } finally { producer.flush(); } }
From source file:com.github.mavogel.ilias.printer.VelocityOutputPrinter.java
/** * Prints the header, content and output to the given print stream with the default template from the classpath. * * @param outputType the desired output type. @see {@link OutputType} * @param contextMap the context for velocity * @throws Exception in case of a error, so the caller can handle it *//*from w ww . j av a 2s . c o m*/ private static void printWithDefaultTemplate(final OutputType outputType, final Map<String, Object> contextMap) throws Exception { VelocityEngine ve = new VelocityEngine(); ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath"); ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName()); ve.init(); Writer writer = null; final String templateName = outputType.getDefaultTemplateLocation(); try { VelocityContext context = new VelocityContext(); contextMap.forEach((k, v) -> context.put(k, v)); Template template = ve.getTemplate(templateName, "UTF-8"); writer = new BufferedWriter(createFileWriter(outputType, templateName)); template.merge(context, writer); writer.flush(); } catch (ResourceNotFoundException rnfe) { LOG.error("Couldn't find the template with name '" + templateName + "'"); throw new Exception(rnfe.getMessage()); } catch (ParseErrorException pee) { LOG.error("Syntax error: problem parsing the template ' " + templateName + "': " + pee.getMessage()); throw new Exception(pee.getMessage()); } catch (MethodInvocationException mie) { LOG.error( "An invoked method on the template '" + templateName + "' threw an error: " + mie.getMessage()); throw new Exception(mie.getMessage()); } catch (Exception e) { LOG.error("Error: " + e.getMessage()); LOG.error("Cause: " + e.getCause()); Arrays.stream(e.getStackTrace()).forEach(LOG::error); throw e; } finally { if (writer != null) writer.close(); } }
From source file:com.pinterest.pinlater.backends.mysql.MySQLBackendUtils.java
/** * Indicates whether an exception is a symptom of MySQL being overloaded or slow. * Typical symptoms are connection pool exhaustion or MySQL connection/socket timeouts. *//*from w w w . ja v a2s . com*/ public static boolean isExceptionIndicativeOfOverload(Exception e) { return e instanceof MySQLNonTransientConnectionException || e instanceof CommunicationsException || (e instanceof SQLNestedException && e.getCause() instanceof NoSuchElementException); }