You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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.