Creating an error type
The core performance test
model includes the generic CBError
object. The CBError
object is a shell that contains the actual error,
the CBErrorType
object. Extend the CBErrorType
object to add new types of errors, including protocol-specific errors.
Associate error-handling behavior with an error by using the CBErrorBehaviorEnum
object.
The following code is an example of creating a new protocol error type from the generic error object:
public abstract class ProtocolErrorTypeImpl extends CBErrorTypeImpl implements ProtocolErrorType {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ProtocolErrorTypeImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected EClass eStaticClass() {
return ErrorsPackage.Literals.PROTOCOL_ERROR_TYPE;
}
public boolean isErrorGenerator(){
return true;
}
/**
* Imports needed at code generation time
* so that the test runs correctly.
*/
public List<String> getExecImport() {
ArrayList<String> imports = new ArrayList<String>();
imports.add("import com.ibm.rational.test.lt.execution.protocol.tes.*;");
imports.add("import com.ibm.rational.test.lt.kernel.action.impl.KThrow;");
imports.add("import com.ibm.rational.test.lt.kernel.services.*;");
return imports;
}
} //ProtocolErrorTypeImpl
The following code is an example of creating a protocol error type from another protocol error type:
public class ProtocolNewErrorTypeImpl extends ProtocolErrorTypeImpl implements ProtocolNewErrorType {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ProtocolNewErrorTypeImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected EClass eStaticClass() {
return ErrorsPackage.Literals.PROTOCOL_NEW_ERROR_TYPE;
}
public String getExecType(){
return "ProtocolNewEvent" ;
}
} //ProtocolNewErrorTypeImpl
For model elements that generate errors, declare these elements to be error generators by using this code:
public boolean isErrorGenerator(){
return true;
}