1 11 package org.eclipse.team.core; 12 13 import java.lang.reflect.InvocationTargetException ; 14 15 import org.eclipse.core.runtime.CoreException; 16 import org.eclipse.core.runtime.IStatus; 17 import org.eclipse.core.runtime.Status; 18 import org.eclipse.team.internal.core.TeamPlugin; 19 20 30 public class TeamException extends CoreException { 31 32 private static final long serialVersionUID = 1L; 34 35 public static final int OK = 0; 37 38 public static final int NOT_CHECKED_IN = -1; 40 41 public static final int NOT_CHECKED_OUT = -2; 43 44 public static final int NO_REMOTE_RESOURCE = -3; 46 47 public static final int IO_FAILED = -4; 49 50 public static final int NOT_AUTHORIZED = -5; 52 53 public static final int UNABLE = -6; 55 56 public static final int CONFLICT = -7; 58 59 63 public TeamException(IStatus status) { 64 super(status); 65 } 66 67 75 public TeamException(String message, Throwable e) { 76 super(new Status(IStatus.ERROR, TeamPlugin.ID, 0, message, e)); 77 } 78 79 84 public TeamException(String message) { 85 this(message, null); 86 } 87 88 93 protected TeamException(CoreException e) { 94 super(asStatus(e)); 95 } 96 97 private static Status asStatus(CoreException e) { 98 IStatus status = e.getStatus(); 99 return new Status(status.getSeverity(), status.getPlugin(), status.getCode(), status.getMessage(), e); 100 } 101 102 108 public static TeamException asTeamException(CoreException e) { 109 if (e instanceof TeamException) { 110 return (TeamException)e; 111 } 112 return new TeamException(e); 113 } 114 115 121 public static TeamException asTeamException(InvocationTargetException e) { 122 Throwable target = e.getTargetException(); 123 if (target instanceof TeamException) { 124 return (TeamException) target; 125 } 126 return new TeamException(new Status(IStatus.ERROR, TeamPlugin.ID, UNABLE, target.getMessage() != null ? target.getMessage() : "", target)); } 128 } 129 | Popular Tags |