From 4fe93d293a94d78930d4982a77155c357a19a55c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 26 Aug 2009 20:07:54 +0200 Subject: [PATCH] Get rid of the class GitException MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The class was based on the CVSException class from the package org.eclipse.team.internal.ccvs.core, as well as SVNException from org.tigris.subversion.subclipse.core. Sadly the latter is not suitable as a basis when contributing source code to the Eclipse Foundation, so it had to be removed. If we need this class and its wrapper-helpers in the future we can base it off CVSException. If we do, we should also add a GitStatus, since TeamStatus is rally meant for API errors only. From: https://bugs.eclipse.org/287743 Signed-off-by: Tor Arne Vestbø Signed-off-by: Shawn O. Pearce --- .../src/org/eclipse/egit/core/GitException.java | 169 --------------------- .../decorators/GitLightweightDecorator.java | 5 +- 2 files changed, 3 insertions(+), 171 deletions(-) delete mode 100644 org.eclipse.egit.core/src/org/eclipse/egit/core/GitException.java diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/GitException.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/GitException.java deleted file mode 100644 index 02c7bc7e..00000000 --- a/org.eclipse.egit.core/src/org/eclipse/egit/core/GitException.java +++ /dev/null @@ -1,169 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. - * Copyright (c) 2003, 2006 Subclipse project 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 - *******************************************************************************/ - -package org.eclipse.egit.core; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.*; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.TeamStatus; - -/** - * A checked exception representing a failure in the Git plugin. - *

- * Git exceptions contain a status object describing the cause of the exception. - *

- * - * @see IStatus - */ -public class GitException extends TeamException { - - private static final long serialVersionUID = 1L; - - /** - * Constructs a new Git exception - * - * @param severity - * @param code - * @param message - * @param e - */ - public GitException(int severity, int code, String message, Throwable e) { - super(new TeamStatus(severity, Activator.getPluginId(), code, message, - e, null)); - } - - /** - * Constructs a new Git exception - * - * @param severity - * @param code - * @param message - */ - public GitException(int severity, int code, String message) { - this(severity, code, message, null); - } - - /** - * Constructs a new Git exception - * - * @param message - * @param e - */ - public GitException(String message, Throwable e) { - this(IStatus.ERROR, UNABLE, message, e); - } - - /** - * Constructs a new Git exception - * - * @param message - */ - public GitException(String message) { - this(message, null); - } - - /** - * Constructs a new Git exception - * - * @param status - */ - public GitException(IStatus status) { - super(status); - } - - /** - * Transform this exception into a CoreException - * - * @return the new CoreException - */ - public CoreException toCoreException() { - IStatus status = getStatus(); - return new CoreException(new Status(status.getSeverity(), status - .getPlugin(), 0, status.getMessage(), this)); - } - - /** - * Static helper method for creating a Git exception - * - * @param resource - * @param message - * @param e - * @return the created exception - */ - public static GitException wrapException(IResource resource, - String message, CoreException e) { - return new GitException(IStatus.ERROR, e.getStatus().getCode(), - message, e); - } - - /** - * Static helper method for creating a Git exception - * - * @param e - * @return the created exception - */ - public static GitException wrapException(Exception e) { - Throwable t = e; - if (e instanceof InvocationTargetException) { - Throwable target = ((InvocationTargetException) e) - .getTargetException(); - if (target instanceof GitException) { - return (GitException) target; - } - t = target; - } - - return new GitException(IStatus.ERROR, UNABLE, - t.getMessage() != null ? t.getMessage() : "", t); //$NON-NLS-1$ - } - - /** - * Static helper method for creating a Git exception - * - * @param e - * @return the created exception - */ - public static GitException wrapException(CoreException e) { - IStatus status = e.getStatus(); - if (!status.isMultiStatus()) { - status = new TeamStatus(status.getSeverity(), Activator - .getPluginId(), status.getCode(), status.getMessage(), e, - null); - } - return new GitException(status); - } - - /** - * Static helper method for creating a Git exception - * - * @param e - * @return the created exception - */ - public static GitException wrapException(IOException e) { - return new GitException(IStatus.ERROR, IO_FAILED, e.getMessage(), e); - } - - /** - * Static helper method for creating a Git exception - * - * @param e - * @return the created exception - */ - public static GitException wrapException(TeamException e) { - if (e instanceof GitException) - return (GitException) e; - else - return new GitException(e.getStatus()); - } -} diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java index eaa0ff98..bea25fb9 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java @@ -31,7 +31,7 @@ import org.eclipse.core.resources.mapping.ResourceMapping; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IStatus; -import org.eclipse.egit.core.GitException; +import org.eclipse.core.runtime.Status; import org.eclipse.egit.core.internal.util.ExceptionCollector; import org.eclipse.egit.core.project.GitProjectData; import org.eclipse.egit.core.project.RepositoryChangeListener; @@ -173,7 +173,8 @@ public class GitLightweightDecorator extends LabelProvider implements helper.decorate(decoration, new DecoratableResourceAdapter(resource)); } catch (IOException e) { - handleException(resource, GitException.wrapException(e)); + handleException(resource, new CoreException(new Status( + IStatus.ERROR, Activator.getPluginId(), e.getMessage(), e))); } } -- 2.11.4.GIT