How can a plugin return a specific error message for display at the GUI?

Comments

2 comments

  • Gido

    You could either throw a runtime exception with your own message or use Preconditons. Please find a small example for how to check two input arguments and return an error message if the second argument is not of the same type:

    import datameer.com.google.common.base.Preconditions;

    public void validateArgumentTypes(ArgumentInfo arguments) {
    super.validateArgumentTypes(arguments);
    if (arguments.getNumArguments() == 2) {
    ValueType returnType = computeReturnSchemaType(arguments);
    ValueType second = arguments.getType(1);
    Preconditions.checkArgument(second.matches(returnType.getValueTypeId()), "Argument 2 must be of type " + returnType);
    }
    }
    0
    Comment actions Permalink
  • Jutta Lachfeld

    Thanks! Throwing a RuntimeException does it. Will keep the Preconditions in mind for later use.

    0
    Comment actions Permalink

Please sign in to leave a comment.