// 
// Decompiled by Procyon v0.6.0
// 

package com.hypixel.hytale.common.util;

import java.io.IOException;
import java.io.Writer;
import java.io.PrintWriter;
import java.io.StringWriter;
import javax.annotation.Nonnull;

public class ExceptionUtil
{
    @Nonnull
    public static String combineMessages(final Throwable thrown, @Nonnull final String joiner) {
        final StringBuilder sb = new StringBuilder();
        for (Throwable throwable = thrown; throwable != null; throwable = throwable.getCause()) {
            if (throwable.getCause() == throwable) {
                return sb.toString();
            }
            if (throwable.getMessage() != null) {
                sb.append(throwable.getMessage()).append(joiner);
            }
        }
        sb.setLength();
        return sb.toString();
    }
    
    public static String toStringWithStack(@Nonnull final Throwable t) {
        try (final StringWriter out = new StringWriter()) {
            t.printStackTrace(new PrintWriter(out));
            return out.toString();
        }
        catch (final IOException ex) {
            return t.toString();
        }
    }
}
