class Utils {

    public static String toString(Throwable t) {
        if (t == null) {
            return null;
        } else {
            StringWriter writer = new StringWriter();
            try (PrintWriter printer = new PrintWriter(writer)) {
                t.printStackTrace(printer);
            }

            return writer.toString();
        }
    }

    private  Utils();

}