Skip to main content
summaryrefslogtreecommitdiffstats
blob: 49979b9829f49fb1d286755aa85b82051b9c07bd (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
72
73
74
75
76
/*******************************************************************************
 * Copyright (c) 2001, 2005 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.jem.internal.proxy.common.remote;
/*


 */

import org.eclipse.jem.internal.proxy.common.CommandException;
/**
 * An error return from a command. This is clean return in that
 * the connection is still valid and alive.
 * After it has been processed the data will be the value retrieved
 * out of the valueobject and made into a proxy.
 */
public class CommandErrorException extends CommandException {
	/**
	 * Comment for <code>serialVersionUID</code>
	 * 
	 * @since 1.1.0
	 */
	private static final long serialVersionUID = 1701752035606593305L;
	private final Object fErrorObject;
	private final int fErrorCode;
	
	public CommandErrorException(int errorCode, Commands.ValueObject errorData) {
		super(errorData.clone());	// Clone it because typically these get reused and cleared out. This way we have our own.
		fErrorObject = null;
		fErrorCode = errorCode;
	}
	
	public CommandErrorException(String msg, int errorCode, Commands.ValueObject errorData, Object errorObject) {
		super(msg, errorData.clone());
		fErrorObject = errorObject;
		fErrorCode = errorCode;		
	}
	
	public Commands.ValueObject getValue() {
		return (Commands.ValueObject) getExceptionData();
	}
		
	public boolean isRecoverable() {
		return true;	// Command errors are recoverable.
	}
	
	/**
	 * Return the error code.
	 */
	public int getErrorCode() {
		return fErrorCode;
	}
	
	/**
	 * Return the error object after conversion to proxy format.
	 */
	public Object getErrorObject() {
		return fErrorObject;
	}
	
	
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return super.toString() + "-- Error code:"+getErrorCode() + (getValue() != null ? " Value data:\"" + getValue().getAsObject() + "\"" : " ") + (fErrorObject != null ? " Error object:\""+fErrorObject.toString()+"\"" : " "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
	}

}

Back to the top