Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to display error message from jira listeners

Vineela Durbha
Contributor
February 14, 2019

I am writing a listener to create an issue. I would like throw the errors on to the jira UI.

I am trying something like below

IssueService.CreateValidationResult createValidationResult = issueService.validateCreate(currentUser, issueInputParameters)


log.error("Validation?: {}" +createValidationResult.isValid())
log.error(createValidationResult.getErrorCollection())
if (createValidationResult.isValid())
{
log.error("entrou no createValidationResult")
IssueService.IssueResult createResult = issueService.create(currentUser, createValidationResult)
if (!createResult.isValid())
{
log.error(createResult.getErrorCollection())

log.error("Error while creating the issue.")

def errorCollection=createResult.getErrorCollection().getErrors().values();


for (String error: errorCollection){
log.debug("inside error collection" +error)
UserMessageUtil.error("Error : ")
}

}
}

 

It is throwing error,but it is happening twice. ANy idea why is it so

1 answer

0 votes
Gezim Shehu [Communardo]
Community Champion
February 15, 2019

I guess there are two entries in Error Collection?

Vineela Durbha
Contributor
February 15, 2019

Hi @Gezim Shehu [Communardo] 

Do you know how to check that

Gezim Shehu [Communardo]
Community Champion
February 15, 2019

for (String error: errorCollection){
log.debug("inside error collection" +error)
UserMessageUtil.error("Error : ")
}

 

if this code is being executed twice, then you have 2 items in the collection.

Simply concat them and run the UserMessageUtil after the for loop closes.

Suggest an answer

Log in or Sign up to answer