Android Throwable to String Convert failException(String message, Throwable got)

Here you can find the source of failException(String message, Throwable got)

Description

Call this if you have an exception you want to fail for!

Parameter

Parameter Description
message a parameter
got this exception

Declaration

public static void failException(String message, Throwable got) 

Method Source Code

//package com.java2s;

import java.util.concurrent.atomic.AtomicBoolean;

public class Main {
    private static final AtomicBoolean isandroid = new AtomicBoolean(false);

    /**/*from w w  w. j ava  2 s  .c o  m*/
     * Call this if you have an exception you want to fail for!
     * @param message
     * @param got this exception
     */
    public static void failException(String message, Throwable got) {
        AssertionError ae = new AssertionError(message);
        if (isandroid.get()) {
            System.out.println("ANDROID: About to throw AssertionError "
                    + "but we cannot initialize the cause... "
                    + "Here follows both the AssertionError and its cause");
            ae.printStackTrace();
            System.out.println("And the cause...");
            got.printStackTrace();
        } else {
            ae.initCause(got);
        }
        throw ae;
    }
}

Related

  1. stringify(Throwable t)
  2. getExceptionMessage(Throwable e)
  3. getExceptionMessage(Throwable ex)
  4. exceptionToString(Throwable t)