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

org.eclipse.ui.internal.ExceptionHandler Maven / Gradle / Ivy

Go to download

This plug-in contains the bulk of the Workbench implementation, and depends on JFace, SWT, and Core Runtime. It cannot be used independently from org.eclipse.ui. Workbench client plug-ins should not depend directly on this plug-in.

The newest version!
/*******************************************************************************
 * Copyright (c) 2000, 2006 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.ui.internal;

import org.eclipse.jface.window.Window;

/**
 * This handler will pass along to the workbench advisor exceptions
 * and errors thrown while running the event loop. However, the
 * ThreadDeath error is simply thrown again, and is not 
 * passed along.
 */
public final class ExceptionHandler implements Window.IExceptionHandler {

    private static final ExceptionHandler instance = new ExceptionHandler();

    /**
     * Returns the singleton exception handler.
     * 
     * @return the singleton exception handler
     */
    public static ExceptionHandler getInstance() {
        return instance;
    }

    private int exceptionCount = 0; // To avoid recursive errors

    private ExceptionHandler() {
        // prevents instantiation
    }

    /* (non-javadoc)
     * @see org.eclipse.jface.window.Window.IExceptionHandler#handleException
     */
    public void handleException(Throwable t) {
        try {
            // Ignore ThreadDeath error as its normal to get this when thread dies
            if (t instanceof ThreadDeath) {
                throw (ThreadDeath) t;
            }

            // Check to avoid recursive errors
            exceptionCount++;
            if (exceptionCount > 2) {
                if (t instanceof RuntimeException) {
					throw (RuntimeException) t;
				}
                throw (Error) t;
            }

            // Let the advisor handle this now
            Workbench wb = Workbench.getInstance();
            if (wb != null) {
                wb.getAdvisor().eventLoopException(t);
            }
        } finally {
            exceptionCount--;
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy