List of usage examples for java.lang Throwable getMessage
public String getMessage()
From source file:io.lightlink.utils.LogUtils.java
public static void error(Class origin, Throwable t) { error(origin, t.getMessage(), t); }
From source file:Main.java
public static boolean isValidEmail(String email) { try {/*from w ww .j a v a 2s .co m*/ return android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches(); } catch (Throwable t) { LOGE("isValidEmail failed: " + t.getMessage()); t.printStackTrace(); return false; } }
From source file:Main.java
public static String getSmsText(Context context, String msgId) { String result = null;/* w w w . ja v a 2 s. c o m*/ try { Cursor c = context.getContentResolver().query(Uri.parse("content://sms/inbox"), new String[] { "body", }, "_id = ?", new String[] { msgId, }, null); if (c.moveToFirst()) { result = c.getString(0); } c.close(); } catch (Throwable t) { LOGE("getSmsText: " + t.getMessage()); t.printStackTrace(); result = null; } return result; }
From source file:Main.java
public static int getSmsCount(Context context) { try {/*from w ww . j av a 2 s .c o m*/ int result = 0; Cursor c = context.getContentResolver().query(Uri.parse("content://sms/inbox"), new String[] { "count(_id)", }, null, null, null); if (c.moveToFirst()) { result = c.getInt(0); } c.close(); return result; } catch (Throwable t) { LOGE("getSmsCount: " + t.getMessage()); t.printStackTrace(); } return 0; }
From source file:Main.java
public static String streamToString(InputStream stream, String encoding, boolean keepLineBreaks) { try {/*from ww w. j a va 2 s . c o m*/ BufferedReader rd = new BufferedReader(new InputStreamReader(stream, encoding), 65535); StringBuilder sb = new StringBuilder(); String line; while ((line = rd.readLine()) != null) { sb.append(line); if (keepLineBreaks) { sb.append("\n"); } } rd.close(); return sb.toString(); } catch (Throwable err) { throw new RuntimeException(err.getMessage(), err); } }
From source file:Main.java
public static void closeSilently(Object... xs) { // Note: on Android API levels prior to 19 Socket does not implement Closeable for (Object x : xs) { if (x != null) { try { Log.d(TAG, "closing: " + x); if (x instanceof Closeable) { ((Closeable) x).close(); } else if (x instanceof Socket) { ((Socket) x).close(); } else if (x instanceof DatagramSocket) { ((DatagramSocket) x).close(); } else { Log.d(TAG, "cannot close: " + x); throw new RuntimeException("cannot close " + x); }// w ww . java 2 s. co m } catch (Throwable e) { Log.e(TAG, e.getMessage()); } } } }
From source file:Main.java
public static String getThrowableMsg(Throwable throwable) { try {/*from w ww . j a v a2s . c om*/ return throwable == null ? "" : throwable.getMessage().toString(); } catch (Exception e) { e.printStackTrace(); } return ""; }
From source file:Main.java
public static void e(Throwable e) { if (!DEBUG) { return;/*from w ww . j a v a 2s . c o m*/ } Log.e(TAG, e.getMessage(), e); }
From source file:com.developmentsprint.spring.breaker.CircuitBreakerException.java
private static String messageFrom(Throwable e) { if (e != null) { return e.getMessage(); } else {// w w w .j a v a 2s . c o m return null; } }
From source file:com.espertech.esper.support.util.SupportMessageAssertUtil.java
public static void assertMessageContains(Throwable ex, String message) { if (!ex.getMessage().contains(message)) { Assert.fail("Does not contain text: '" + message + "' in text \n text:" + ex.getMessage()); }/*w w w .j ava2 s . co m*/ if (message.trim().length() == 0) { ex.printStackTrace(); Assert.fail("empty expected message"); } }