If I throw it, everything is ok:
error = new InvalidInputException("Main error message:")
throw error
But if I add errors, the main message is replaced to a default error message:
error = new InvalidInputException("Main error message:")
error.addError("error1","error msg")
throw error
You already saw it and know how solve?
Hi @Rafael Costa,
The class you're using is the class:
com.opensymphony.workflow.InvalidInputException
This class distinguishes errors and generic errors. Thus, within it, an error map and a list for generic errors are populated.
You can find the source code of this class here.
As you will notice, the instruction:
error.addError("error1","error msg")
It's equivalent to education:
error.errors.put("error1","error msg")
So, you're populating the errors map.
Instead, if you use the instruction with only a parameter:
error.addError("error1")
You're populating the generic errors list.
You can observe this by running the following code from the ScriptRunner console:
import com.opensymphony.workflow.InvalidInputException
def error = new InvalidInputException("Main error message:")
error.addError("error1","error msg")
error.errors.put("error2", "error msg2")
error.addError("errorA")
error.addError("errorB")
throw error
I hope this helps you to resolve your doubts.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.