Example usage for java.lang Throwable printStackTrace

List of usage examples for java.lang Throwable printStackTrace

Introduction

In this page you can find the example usage for java.lang Throwable printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:icehx.openiab.OpenIAB.java

public static boolean verifyInventoryPurchase(String sku) {
    try {// w  ww  .  j  a v a 2  s  .  c  o  m
        if (hasInventory() && inventory.hasPurchase(sku)) {
            Purchase p = inventory.getPurchase(sku);
            String base64Key = STORE_KEYS_MAP.get(mHelper.getConnectedAppstoreName());
            if (p.getSku().startsWith("android.test.")) {
                return true;
            }
            return Security.verifyPurchase(base64Key, p.getOriginalJson(), p.getSignature());
        }
    } catch (Throwable e) {
        e.printStackTrace();
    }
    return false;
}

From source file:eu.wordnice.wnconsole.WNCUtils.java

/*** PROTECTED ***/
protected static Handler.OneVoidHandler<Logger> createOnDisable(final ServerSocket sock) {
    return new Handler.OneVoidHandler<Logger>() {
        @Override// ww w . j  a  v a  2  s  .  c o  m
        public void handle(Logger lg) {
            try {
                sock.close();
                lg.info("WNConsole was disabled!");
            } catch (Throwable tr) {
                lg.severe("Ups, cannot close server service! Details:");
                tr.printStackTrace();
            }
        }
    };
}

From source file:icehx.openiab.OpenIAB.java

private static void callback_call(final String method, final Object[] params) {
    Extension.callbackHandler.post(new Runnable() {
        @Override/*from ww w. ja v  a  2  s  .c om*/
        public void run() {
            try {
                callback.call(method, params);
            } catch (Throwable e) {
                e.printStackTrace();
            }
        } // run
    });
}

From source file:org.fusesource.meshkeeper.util.internal.IntrospectionSupport.java

private static void addFields(Object target, Class<?> startClass, Class<?> stopClass,
        LinkedHashMap<String, Object> map) {

    if (startClass != stopClass) {
        addFields(target, startClass.getSuperclass(), stopClass, map);
    }//from w  w  w . j  a  v a  2s. c  om

    Field[] fields = startClass.getDeclaredFields();
    for (int i = 0; i < fields.length; i++) {
        Field field = fields[i];
        if (Modifier.isStatic(field.getModifiers()) || Modifier.isTransient(field.getModifiers())
                || Modifier.isPrivate(field.getModifiers())) {
            continue;
        }

        try {
            field.setAccessible(true);
            Object o = field.get(target);
            if (o != null && o.getClass().isArray()) {
                try {
                    o = Arrays.asList((Object[]) o);
                } catch (Throwable e) {
                }
            }
            map.put(field.getName(), o);
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }

}

From source file:icehx.openiab.OpenIAB.java

public static void createService(final HaxeObject callback, final int verifyMode, final boolean debugLog,
        final String[] preferredStoreNames, final boolean checkInventory, final String[] availableStoreNames,
        final int storeSearchStrategy) {
    Extension.callbackHandler.post(new Runnable() {
        @Override//from ww w. j  a  v  a 2  s  . c o m
        public void run() {
            try {
                _createService(callback, verifyMode, debugLog, preferredStoreNames, checkInventory,
                        availableStoreNames, storeSearchStrategy);
            } catch (Throwable e) {
                e.printStackTrace();
            }
        } // run
    });
}

From source file:com.hazelcast.qasonar.utils.GitHubUtils.java

private static Object execute(TimeTrackerLabel label, Callable callable) {
    long started = System.nanoTime();
    try {// w  ww.  j  av  a2s. co  m
        while (true) {
            try {
                return callable.call();
            } catch (Throwable t) {
                int counter = EXCEPTION_COUNTER.incrementAndGet();
                if (counter % GITHUB_EXCEPTION_LOG_FREQUENCY == 0) {
                    counter = 0;
                    EXCEPTION_COUNTER.set(0);
                    t.printStackTrace();
                }
                sleepMillis(GITHUB_EXCEPTION_DELAY_MILLIS * counter);
            }
        }
    } finally {
        record(label, System.nanoTime() - started);
    }
}

From source file:com.meterware.httpunit.HttpUnitUtils.java

/**
 * handle Exceptions and thowables/*  www.  j a v  a 2s . com*/
 * @param th 
 */
public static void handleException(Throwable th) {
    if (EXCEPTION_DEBUG) {
        th.printStackTrace();
    }
}

From source file:com.aw.support.reflection.MethodInvoker.java

public static Object invoke(Object target, String methodName, Object[] parameters) throws Throwable {
    Object result = null;/*from  ww  w. j a v  a 2s.co m*/
    try {
        Class cls = target.getClass();
        Class[] paramTypes = new Class[parameters.length];
        for (int i = 0; i < paramTypes.length; i++) {
            paramTypes[i] = parameters[i].getClass();
        }
        Method method = cls.getMethod(methodName, paramTypes);
        method.setAccessible(true);
        result = method.invoke(target, parameters);
    } catch (Throwable e) {
        if (e.getCause() instanceof AWException) {
            throw ((AWException) e.getCause());
        }
        e.printStackTrace();
        throw e;
    }
    return result;
}

From source file:forge.error.BugReporter.java

/**
 * Shows exception information in a format ready to post to the forum as a
 * crash report. Uses the exception's message as the reason if message is
 * null./*w ww  .  j  a v a 2 s.co m*/
 */
public static void reportException(final Throwable ex, final String message) {
    if (ex == null) {
        return;
    }
    if (message != null) {
        System.err.printf("%s > %s%n", FThreads.debugGetCurrThreadId(), message);
    }
    System.err.print(FThreads.debugGetCurrThreadId() + " > ");
    ex.printStackTrace();

    final StringBuilder sb = new StringBuilder();
    sb.append("Description: [describe what you were doing when the crash occurred]\n\n");
    buildSpoilerHeader(sb, ex.getClass().getSimpleName());
    sb.append("\n\n");
    if (null != message && !message.isEmpty()) {
        sb.append(FThreads.debugGetCurrThreadId()).append(" > ").append(message).append("\n");
    }

    final StringWriter sw = new StringWriter();
    final PrintWriter pw = new PrintWriter(sw);
    ex.printStackTrace(pw);

    final String swStr = sw.toString();
    if (ex instanceof StackOverflowError && swStr.length() >= STACK_OVERFLOW_MAX_MESSAGE_LEN) {
        // most likely a cycle.  only take first portion so the message
        // doesn't grow too large to post
        sb.append(swStr, 0, STACK_OVERFLOW_MAX_MESSAGE_LEN);
        sb.append("\n... (truncated)");
    } else {
        sb.append(swStr);
    }

    buildSpoilerFooter(sb);

    GuiBase.getInterface().showBugReportDialog("Report a crash", sb.toString(), true);
}

From source file:mitll.xdata.dataset.kiva.ingest.KivaIngest.java

public static int executePreparedStatement(PreparedStatement statement, List<String> types, List<String> values)
        throws Exception {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
    try {//from www .j  a  v a 2 s .  c  om
        for (int i = 0; i < types.size(); i++) {
            String type = TYPE_TO_DB.get(types.get(i).toUpperCase());
            String value = values.get(i);
            if (value != null && value.trim().length() == 0) {
                value = null;
            }
            if (type.equalsIgnoreCase("INT")) {
                if (value == null) {
                    statement.setNull(i + 1, java.sql.Types.INTEGER);
                } else {
                    statement.setInt(i + 1, Integer.parseInt(value, 10));
                }
            } else if (type.equalsIgnoreCase("DOUBLE")) {
                if (value == null) {
                    statement.setNull(i + 1, java.sql.Types.DOUBLE);
                } else {
                    statement.setDouble(i + 1, Double.parseDouble(value));
                }
            } else if (type.equalsIgnoreCase("BOOLEAN")) {
                if (value == null) {
                    statement.setNull(i + 1, java.sql.Types.BOOLEAN);
                } else {
                    statement.setBoolean(i + 1, Boolean.parseBoolean(value));
                }
            } else if (type.equalsIgnoreCase("VARCHAR")) {
                statement.setString(i + 1, value);
            } else if (type.equalsIgnoreCase("TIMESTAMP")) {
                if (value == null) {
                    statement.setNull(i + 1, java.sql.Types.TIMESTAMP);
                } else {
                    statement.setTimestamp(i + 1, new Timestamp(sdf.parse(value).getTime()));
                }
            }
        }
    } catch (Throwable e) {
        System.out.println("types = " + types);
        System.out.println("values = " + values);
        System.out.println("types.size() = " + types.size());
        System.out.println("values.size() = " + values.size());
        e.printStackTrace();
        System.out.println(e.getMessage());
        throw new Exception(e);
    }
    return statement.executeUpdate();
}