All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.beanfabrics.util.ExceptionUtil Maven / Gradle / Ivy

Go to download

Beanfabrics is a component framework for building Java desktop applications according to the Presentation Model Pattern with Swing.

There is a newer version: 1.5.0
Show newest version
/*
 * Beanfabrics Framework Copyright (C) by Michael Karneim, beanfabrics.org
 * Use is subject to license terms. See license.txt.
 */
// TODO javadoc - remove this comment only when the class and all non-public
// methods and fields are documented
package org.beanfabrics.util;

/**
 * The ExceptionUtil is a singleton that provides access to an
 * {@link IExceptionHandler} which is used by the Beanfabrics framework to
 * handle exceptions.
 * 
 * @author Max Gensthaler
 */
public class ExceptionUtil {
    private static final ExceptionUtil INSTANCE = new ExceptionUtil();
    private IExceptionHandler exceptionHandler;

    private ExceptionUtil() {
        //
    }

    public static ExceptionUtil getInstance() {
        return INSTANCE;
    }

    public void handleException(String message, Throwable t) {
        if (this.exceptionHandler != null) {
            this.exceptionHandler.handleException(message, t);
        } else {
            t.printStackTrace();
            ErrorPane.showErrorDialog(message, t);
        }
    }

    public void setExceptionHandler(IExceptionHandler handler) {
        this.exceptionHandler = handler;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy