// Path: src/main/java/com/github/xsavikx/androidscreencast/exception/AndroidScreenCastRuntimeException.java
// public class AndroidScreenCastRuntimeException extends RuntimeException {
// 
//     private String additionalInformation;
// 
//     public AndroidScreenCastRuntimeException() {
//     }
// 
//     public AndroidScreenCastRuntimeException(String message) {
//         super(message);
//     }
// 
// 
//     public AndroidScreenCastRuntimeException(String message, String additionalInformation) {
//         super(message);
//         this.additionalInformation = additionalInformation;
//     }
// 
//     public AndroidScreenCastRuntimeException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public AndroidScreenCastRuntimeException(Throwable cause) {
//         super(cause);
//     }
// 
//     public AndroidScreenCastRuntimeException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
//         super(message, cause, enableSuppression, writableStackTrace);
//     }
// 
//     public String getAdditionalInformation() {
//         return additionalInformation;
//     }
// }
// 
// Path: src/main/java/com/github/xsavikx/androidscreencast/exception/IORuntimeException.java
// public final class IORuntimeException extends AndroidScreenCastRuntimeException {
// 
//     public IORuntimeException(String message, IOException cause) {
//         super(message, cause);
//     }
// 
//     public IORuntimeException(IOException cause) {
//         super(cause);
//     }
// 
//     public IORuntimeException(String message, IOException cause, boolean enableSuppression, boolean writableStackTrace) {
//         super(message, cause, enableSuppression, writableStackTrace);
//     }
// }
// 
// Path: src/main/java/com/github/xsavikx/androidscreencast/util/StringUtils.java
// public final class StringUtils {
// 
//     private StringUtils() {
//     }
// 
//     public static boolean isNotEmpty(final CharSequence charSequence) {
//         return charSequence != null && charSequence.length() > 0;
//     }
// }


import com.github.xsavikx.androidscreencast.exception.AndroidScreenCastRuntimeException;
import com.github.xsavikx.androidscreencast.exception.IORuntimeException;
import com.github.xsavikx.androidscreencast.util.StringUtils;
import javax.swing.*;
import java.awt.*;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
        errorDialogLabel.setText(ex.getClass().getSimpleName());
        try (StringWriter stringWriter = new StringWriter()) {
            AndroidScreenCastRuntimeException realCause = getCause(ex);
            if (realCause != null) {
                errorDialogLabel.setText(realCause.getClass().getSimpleName());
                if (StringUtils.isNotEmpty(realCause.getMessage()))
                    stringWriter.append(realCause.getMessage()).append('\n').append('\n');
                if (StringUtils.isNotEmpty(realCause.getAdditionalInformation()))
                    stringWriter.append(realCause.getAdditionalInformation());
            } else {
                if (StringUtils.isNotEmpty(ex.getMessage()))
                    stringWriter.append(ex.getMessage()).append('\n').append('\n');
                ex.printStackTrace(new PrintWriter(stringWriter));
            }
            errorDescription.setText(stringWriter.toString());
        } catch (IOException ioe) {
            throw new IORuntimeException(ioe);
        }
    }

    private Throwable getRealException(Throwable e) {
        if (e.getClass() == RuntimeException.class && e.getCause() != null)
            return e.getCause();
        return e;
    }

    private AndroidScreenCastRuntimeException getCause(Throwable ex) {
        Throwable cause = ex.getCause();
        while (cause != null) {
            if (cause instanceof AndroidScreenCastRuntimeException) {
// Path: src/main/java/com/github/xsavikx/androidscreencast/exception/AndroidScreenCastRuntimeException.java
// public class AndroidScreenCastRuntimeException extends RuntimeException {
// 
//     private String additionalInformation;
// 
//     public AndroidScreenCastRuntimeException() {
//     }
// 
//     public AndroidScreenCastRuntimeException(String message) {
//         super(message);
//     }
// 
// 
//     public AndroidScreenCastRuntimeException(String message, String additionalInformation) {
//         super(message);
//         this.additionalInformation = additionalInformation;
//     }
// 
//     public AndroidScreenCastRuntimeException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public AndroidScreenCastRuntimeException(Throwable cause) {
//         super(cause);
//     }
// 
//     public AndroidScreenCastRuntimeException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
//         super(message, cause, enableSuppression, writableStackTrace);
//     }
// 
//     public String getAdditionalInformation() {
//         return additionalInformation;
//     }
// }
// 
// Path: src/main/java/com/github/xsavikx/androidscreencast/exception/IORuntimeException.java
// public final class IORuntimeException extends AndroidScreenCastRuntimeException {
// 
//     public IORuntimeException(String message, IOException cause) {
//         super(message, cause);
//     }
// 
//     public IORuntimeException(IOException cause) {
//         super(cause);
//     }
// 
//     public IORuntimeException(String message, IOException cause, boolean enableSuppression, boolean writableStackTrace) {
//         super(message, cause, enableSuppression, writableStackTrace);
//     }
// }
// 
// Path: src/main/java/com/github/xsavikx/androidscreencast/util/StringUtils.java
// public final class StringUtils {
// 
//     private StringUtils() {
//     }
// 
//     public static boolean isNotEmpty(final CharSequence charSequence) {
//         return charSequence != null && charSequence.length() > 0;
//     }
// }


// Path: src/main/java/com/github/xsavikx/androidscreencast/ui/JDialogError.java
import com.github.xsavikx.androidscreencast.exception.AndroidScreenCastRuntimeException;
import com.github.xsavikx.androidscreencast.exception.IORuntimeException;
import com.github.xsavikx.androidscreencast.util.StringUtils;
import javax.swing.*;
import java.awt.*;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;

        errorDialogLabel.setText(ex.getClass().getSimpleName());
        try (StringWriter stringWriter = new StringWriter()) {
            AndroidScreenCastRuntimeException realCause = getCause(ex);
            if (realCause != null) {
                errorDialogLabel.setText(realCause.getClass().getSimpleName());
                if (StringUtils.isNotEmpty(realCause.getMessage()))
                    stringWriter.append(realCause.getMessage()).append('\n').append('\n');
                if (StringUtils.isNotEmpty(realCause.getAdditionalInformation()))
                    stringWriter.append(realCause.getAdditionalInformation());
            } else {
                if (StringUtils.isNotEmpty(ex.getMessage()))
                    stringWriter.append(ex.getMessage()).append('\n').append('\n');
                ex.printStackTrace(new PrintWriter(stringWriter));
            }
            errorDescription.setText(stringWriter.toString());
        } catch (IOException ioe) {
            throw new IORuntimeException(ioe);
        }
    }

    private Throwable getRealException(Throwable e) {
        if (e.getClass() == RuntimeException.class && e.getCause() != null)
            return e.getCause();
        return e;
    }

    private AndroidScreenCastRuntimeException getCause(Throwable ex) {
        Throwable cause = ex.getCause();
        while (cause != null) {
            if (cause instanceof AndroidScreenCastRuntimeException) {
                return (AndroidScreenCastRuntimeException) cause;