Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package it.foo;
- import com.scms.api.sce.OperationArguments;
- import com.scms.api.sce.OperationException;
- import com.scms.api.sce.OperationResultHandler;
- public class SceResultHandler implements OperationResultHandler {
- long errorCounter = 0;
- String returnMessage = "";
- public void handleOperationResult(Object[] result, OperationArguments handback) {
- for(int index=0; index < result.length; index++) {
- if (result[index] != null) {
- errorCounter++;
- // Extract error details
- OperationException ex = (OperationException)result[index];
- // Extract operation name
- String operationName = handback.getOperationName();
- // Print operation name and error message
- returnMessage += "- Error number: " + errorCounter + "\n";
- returnMessage += "- Operation: "+ operationName + "\n";
- returnMessage += "- Message: "+ ex.getLocalizedMessage() + "\n";
- // Print operation arguments
- returnMessage += "- Arguments:\n";
- String[] argNames = handback.getArgumentNames();
- if (argNames!=null) {
- for (int j=0; j < argNames.length; j++) {
- returnMessage += "\t" + argNames[j] + " = " + handback.getArgument(argNames[j]) + "\n";
- }
- }
- }
- }
- // if no errors, we exit
- if(errorCounter > 0) {
- System.err.println(returnMessage);
- System.exit(1);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement