/*
 * Copyright (C) 2024 ctecinf.com.br
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package br.com.ctecinf.jetty;

import javax.swing.JOptionPane;

/**
 *
 * @author Cássio Conceição
 * @since 23/06/2024
 * @version 2406
 * @see http://ctecinf.com.br/
 */
public class JettyException extends Exception {

    public JettyException(String message) {
        super(message);
    }

    public JettyException(Throwable cause) {
        super(cause);
    }

    public static String format(Exception exception) {
        if (exception == null) {
            return "";
        }
        StringBuilder msg = new StringBuilder();
        msg.append(exception.getMessage()).append("\n\n");
        for (StackTraceElement stackTraceElement : exception.getStackTrace()) {
            msg.append(stackTraceElement).append("\n");
        }
        return msg.toString();
    }

    public void html() {

    }

    public void show() {
        System.err.println(this);
        JOptionPane.showMessageDialog(null, this, "Exception", JOptionPane.ERROR_MESSAGE);
    }

    @Override
    public String toString() {
        return format(this);
    }

}
