Exceptions in the Component Executor

You must code your component executor to handle exceptions of all kinds.

In your runtime class (which implements com.engineous.sdk.runtime.Component), all the methods are defined to throw exceptions of type RtException. If a runtime method throws an exception of this type, the infrastructure will put an “error” severity level message in the job log and mark the run with a condition code of “failed.” The job log will include the exception details, stack traceback, and chained exceptions (if any). Here is a typical execute() method:

public void execute(RuntimeEnv runEnv) throws RtException {
   try {
      // Get my component properties
      parallel = 
      runEnv.getScalarProperty("parallel").getValueObj().getAsBoolean();
      useDelay = 
      runEnv.getScalarProperty("useDelay").getValueObj().getAsBoolean();
   }
   catch (com.engineous.sdk.vars.VarElementNotFoundException e) {
      // The model was missing a component property (should never 
      happen)
      throw new RtMissingPropertyException(e, "Missing expected component
      property.");
   }
   catch (VariableException ve) {
      // Some other problem accessing the properties
      throw new RtException(ve, "Unable to access component 
      properties.");
   }

// ... maybe similar try-catch block for parameters, or we might
// ... iterate the set of parameters.  Either way, we should 
catch
// ... exceptions and re-throw as RtExceptions.  Having separate 
try-catch
// ... blocks allows the exception text to be more specific about 
what we
// ... were doing when the failure occurred (e.g. getting our 
properties,
// ... getting parameters, or doing some component logic).

   try {
      // ... processing logic of my component ...
   }
   catch (Exception e) {
      // Rethrow any errors during processing
     throw new RtException(e, "My component failed.");
   }
}

Although the methods of the component interfaces (editor and executor) are defined to throw a specific type, the infrastructure will actually catch all Throwables and handle them to ensure that an errant component does not bring down the entire Design Gateway or SIMULIA Execution Engine station when connected to a SIMULIA Execution Engine. However, if a component does a System.exit(), there is no way to prevent the system from shutting down.