Skip to main content
summaryrefslogtreecommitdiffstats
blob: 1991e57d0d4c7835e5a3aaad1d88821dbc27a549 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package org.eclipse.team.internal.ccvs.core.connection;

/*
 * (c) Copyright IBM Corp. 2000, 2002.
 * All Rights Reserved.
 */

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.team.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.ccvs.core.CVSStatus;
import org.eclipse.team.internal.ccvs.core.CVSException;

/**
 * Client has received an error response from the server. 
 */
public class CVSServerException extends CVSException {
	
	/**
	 * Return true if the exception from the cvs server is the no tag error, and false
	 * otherwise.
	 */
	public boolean isNoTagException() {
		IStatus status = getStatus();
		if ( ! status.isMultiStatus())
			return false;
		IStatus[] children = ((MultiStatus)status).getChildren();
		if (children.length != 1)
			return false;
		if (children[0].getCode() == CVSStatus.NO_SUCH_TAG)
			return true;
		return false;
	}
	
	/**
	 * Return true if the exceptions status contains any error status messages
	 */
	public boolean containsErrors() {
		IStatus status = getStatus();
		if ( ! status.isMultiStatus())
			return status.getSeverity() == IStatus.ERROR;
		IStatus[] children = ((MultiStatus)status).getChildren();
		for (int i=0;i<children.length;i++) {
			if (children[i].getSeverity() == IStatus.ERROR)
				return true;
		}
		return false;
	}
	
	/**
	 * Return the CVSServerException for the given error message and error list
	 * 
	 * This is public due to packaging and should not be used by clients.
	 */	
	public static CVSServerException forError(String message, IStatus[] children) {
		if (children.length > 0) {
			return new CVSServerException(message, children);
		} else {
			return new CVSServerException(new CVSStatus(IStatus.ERROR, CVSStatus.SERVER_ERROR, message, null));
		}
	}
	
	public CVSServerException(IStatus status) {
		super(status);
	}
	
	private CVSServerException(String message, IStatus[] children) {
		super(new MultiStatus(CVSProviderPlugin.ID, CVSStatus.SERVER_ERROR, children, message, null));
	}
}

Back to the top