List of usage examples for java.lang Throwable getMessage
public String getMessage()
From source file:net.sf.groovyMonkey.GroovyMonkeyPlugin.java
public static void logExceptionWarning(final Throwable throwable) { logExceptionWarning(throwable.getMessage(), throwable); }
From source file:com.addbean.autils.tools.OtherUtils.java
public static void trustAllHttpsURLConnection() { // Create a trust manager that does not validate certificate chains if (sslSocketFactory == null) { TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { @Override/*w w w . j a v a 2 s . c o m*/ public X509Certificate[] getAcceptedIssuers() { return null; } @Override public void checkClientTrusted(X509Certificate[] certs, String authType) { } @Override public void checkServerTrusted(X509Certificate[] certs, String authType) { } } }; try { SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(null, trustAllCerts, null); sslSocketFactory = sslContext.getSocketFactory(); } catch (Throwable e) { Log.e("OtherUtils", e.getMessage()); } } if (sslSocketFactory != null) { HttpsURLConnection.setDefaultSSLSocketFactory(sslSocketFactory); HttpsURLConnection.setDefaultHostnameVerifier( org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); } }
From source file:gov.nih.nci.evs.reportwriter.test.lexevs.Util.java
/** * Outputs a standard message to console indicating supported command line * options.// w ww .jav a2 s . c o m * * @param syntax * Named syntax. * @param options * Provided options. * @param example * Example usage, if applicable. * @param parseErr * Error that occurred parsing the command line, if applicable. */ static void displayCommandOptions(String syntax, Options options, String example, Throwable parseErr) { displayMessage(""); if (parseErr != null) { displayMessage("Unable to parse command options>> " + parseErr.getMessage()); displayMessage(""); } try { new HelpFormatter().printHelp(_printWriter, 80, syntax, "", options, 0, 0, "", true); } finally { _printWriter.flush(); } if (example != null) { displayMessage(""); displayMessage("Example: " + example); } }
From source file:com.ctriposs.rest4j.common.testutils.DataAssert.java
/** * Assert that the data in two collections is the same. * Assumes that the underlying {@link Iterator} of each collection returns elements in the same order. * * @param actual the object under test/*ww w .j av a2s. c o m*/ * @param expected the expected object * @param validationOptions the {@link ValidationOptions} that should be used for fix-up and coercion. Can be null. * @param <T> */ public static <T extends RecordTemplate> void assertRecordTemplateCollectionsEqual(Collection<T> actual, Collection<T> expected, ValidationOptions validationOptions) { if (actual == null || expected == null) { Assert.assertEquals(actual, expected, "Only one of the two collections is null."); return; } Assert.assertEquals(actual.size(), expected.size(), "The sizes of the collections are not the same!"); Iterator<T> actualIterator = actual.iterator(); Iterator<T> expectedIterator = expected.iterator(); int index = 0; while (actualIterator.hasNext() && expectedIterator.hasNext()) { T actualRecordTemplate = actualIterator.next(); T expectedRecordTemplate = expectedIterator.next(); try { assertRecordTemplateDataEqual(actualRecordTemplate, expectedRecordTemplate, validationOptions); } catch (Throwable t) { Assert.fail( "The record templates are not equal at index " + index + ". Error is: " + t.getMessage()); } index++; } }
From source file:com.qmetry.qaf.automation.util.JSONUtil.java
public static <T> void writeJsonObjectToFile(final String file, final T obj) { File f = new File(file); try {/* ww w . j a va 2 s. co m*/ Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create(); String jsonStr = gson.toJson(obj, obj.getClass()); FileUtil.writeStringToFile(f, jsonStr, "UTF-8"); } catch (Throwable e) { System.err.println("Unable to write : " + obj.getClass().getCanonicalName() + " in file: " + file + " :" + e.getMessage()); logger.error("Unable to write : " + obj.getClass().getCanonicalName() + " in file: " + file + " :" + e.getMessage()); } }
From source file:esg.common.Utils.java
public static boolean poke(String host, int port, int timeout) { boolean ret = false; Socket socket = null;/*w w w .j a v a2s . c o m*/ try { (socket = new Socket()).connect(new InetSocketAddress(java.net.InetAddress.getByName(host), port), timeout); socket.close(); ret = true; } catch (Throwable t) { log.error(t.getMessage()); } finally { try { socket.close(); } catch (Throwable t) { } } return ret; }
From source file:esg.common.Utils.java
public static String hashSum(String plaintext) { try {/*from w w w .j a va 2 s . com*/ if (quickHash == null) quickHash = new QuickHash(); return quickHash.sum(plaintext); } catch (Throwable t) { System.out.println(t.getMessage()); return null; } }
From source file:com.ejisto.modules.vertx.handler.Boilerplate.java
public static void writeError(HttpServerRequest req, Throwable e) { req.response().setStatusCode(INTERNAL_SERVER_ERROR.code()) .setStatusMessage(StringUtils.defaultString(e.getMessage(), "exception")).end(); }
From source file:com.thinkbiganalytics.nifi.rest.client.NifiRestClientExceptionTranslator.java
public static Throwable translateException(Throwable e) { //Return if its already translated to a NifiClientRuntimeException if (e instanceof NifiClientRuntimeException) { return e; }// w w w . j ava 2 s . co m if (e instanceof NotFoundException) { return new NifiComponentNotFoundException(e.getMessage()); } else if (e instanceof NullPointerException) { return new NifiConnectionException("Verify NiFi is running and try again", e); } else if (e instanceof ProcessingException) { int throwables = ExceptionUtils.getThrowableCount(e); if (throwables > 1) { Throwable rootCause = ExceptionUtils.getRootCause(e); if (rootCause instanceof NoHttpResponseException || rootCause instanceof HttpHostConnectException || rootCause instanceof ConnectException) { //connection error return new NifiConnectionException(e.getMessage(), e); } } } return new NifiClientRuntimeException(e); }
From source file:io.opentracing.contrib.elasticsearch.common.SpanDecorator.java
private static Map<String, Object> errorLogs(Throwable throwable) { Map<String, Object> errorLogs = new HashMap<>(4); errorLogs.put("event", Tags.ERROR.getKey()); errorLogs.put("error.kind", throwable.getClass().getName()); errorLogs.put("error.object", throwable); errorLogs.put("message", throwable.getMessage()); StringWriter sw = new StringWriter(); throwable.printStackTrace(new PrintWriter(sw)); errorLogs.put("stack", sw.toString()); return errorLogs; }