From: "Tor Arne Vestbø" <torarnv@gmail.com>
To: "Shawn O. Pearce" <spearce@spearce.org>,
Robin Rosenberg <robin.rosenberg@dewire.com>
Cc: git@vger.kernel.org
Subject: [EGIT PATCH v2 03/12] Add a specialized team exception for Git
Date: Wed, 11 Feb 2009 19:40:05 +0100 [thread overview]
Message-ID: <1234377614-23798-4-git-send-email-torarnv@gmail.com> (raw)
In-Reply-To: <1234377614-23798-3-git-send-email-torarnv@gmail.com>
Copied largly from org.eclipse.team.internal.ccvs.core (CVS) and
org.tigris.subversion.subclipse.core (SVN), and then cleaned up.
Signed-off-by: Tor Arne Vestbø <torarnv@gmail.com>
---
.../src/org/spearce/egit/core/GitException.java | 168 ++++++++++++++++++++
1 files changed, 168 insertions(+), 0 deletions(-)
create mode 100644 org.spearce.egit.core/src/org/spearce/egit/core/GitException.java
diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/GitException.java b/org.spearce.egit.core/src/org/spearce/egit/core/GitException.java
new file mode 100644
index 0000000..7217fb7
--- /dev/null
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/GitException.java
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * 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
+ * See LICENSE for the full license text, also available.
+ *******************************************************************************/
+
+package org.spearce.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.
+ * <p>
+ * Git exceptions contain a status object describing the cause of the exception.
+ * </p>
+ *
+ * @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());
+ }
+}
--
1.6.1.2.309.g2ea3
next prev parent reply other threads:[~2009-02-11 18:41 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-11 18:40 [EGIT PATCH v2 00/12] Support customizable label decorations Tor Arne Vestbø
2009-02-11 18:40 ` [EGIT PATCH v2 01/12] Add support code to handle plugin property changes Tor Arne Vestbø
2009-02-11 18:40 ` [EGIT PATCH v2 02/12] Use Set instead of array to keep track of change listeners Tor Arne Vestbø
2009-02-11 18:40 ` Tor Arne Vestbø [this message]
2009-02-11 18:40 ` [EGIT PATCH v2 04/12] Add new class ExceptionCollector for grouping exceptions Tor Arne Vestbø
2009-02-11 18:40 ` [EGIT PATCH v2 05/12] Add new class SWTUtils with helper-methods for creating controls Tor Arne Vestbø
2009-02-11 18:40 ` [EGIT PATCH v2 06/12] Implement basic customizable label decorations with preferences Tor Arne Vestbø
2009-02-11 18:40 ` [EGIT PATCH v2 07/12] Add binding for name of the current branch Tor Arne Vestbø
2009-02-11 18:40 ` [EGIT PATCH v2 08/12] Add icon decoration for tracked and untracked resources Tor Arne Vestbø
2009-02-11 18:40 ` [EGIT PATCH v2 09/12] Implement icon and text decorations of various resource states Tor Arne Vestbø
2009-02-11 18:40 ` [EGIT PATCH v2 10/12] Don't decorate every single resource on repository change Tor Arne Vestbø
2009-02-11 18:40 ` [EGIT PATCH v2 11/12] Expose the underlying resource entries in ContainerTreeIterator Tor Arne Vestbø
2009-02-11 18:40 ` [EGIT PATCH v2 12/12] Implement label decorations for folders and projects Tor Arne Vestbø
2009-02-12 0:02 ` Robin Rosenberg
2009-02-11 22:16 ` [EGIT PATCH v2 08/12] Add icon decoration for tracked and untracked resources Robin Rosenberg
2009-02-11 22:46 ` [EGIT PATCH 08/12 v3] " Tor Arne Vestbø
2009-02-16 20:57 ` [EGIT PATCH v2 00/12] Support customizable label decorations Robin Rosenberg
2009-02-16 22:49 ` Tor Arne Vestbø
2009-02-17 5:52 ` Robin Rosenberg
2009-02-17 17:51 ` [EGIT PATCH 13/12] Add new file tree iterator that can adapt into a ContainerTreeIterator Tor Arne Vestbø
2009-02-17 17:52 ` [EGIT PATCH 14/12] Allow project decorations regardless of repository root location Tor Arne Vestbø
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1234377614-23798-4-git-send-email-torarnv@gmail.com \
--to=torarnv@gmail.com \
--cc=git@vger.kernel.org \
--cc=robin.rosenberg@dewire.com \
--cc=spearce@spearce.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).