Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,463,526
Community Members
 
Community Events
176
Community Groups

Could you help me to custom an groovy InvalidInputException?

Edited

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?

1 answer

0 votes

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.

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events