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

How to display a nice error message when a Jira servlet plugin gets an error or exception?

Sorin Sbarnea (Citrix)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 22, 2012

I am trying to port a plugin from an ancient version of Jira to make it Jira 5.x compatible and I do want to display nice messages when someting goes wrong, messages that will appear in the UI.

The plugin is a servlet that is using velocity templates (.vm) for the pages.

I do want to display AUI Error message when an error occurs or an exception inside the plugin.

Is this possible how?

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Florin Manaila
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 22, 2012

Gather the errors in a catch block and add them to the velocity context.

try {
....
} catch (Throwable t) {
      velocityContext.add("error", true);
      velocityContext.add("error.message", "Some error message");
}

... and then check the $error in the velocity file.

Alexander Urzhumtsev June 19, 2013

Tell me pls, how to get velocityContext?

Alexander Urzhumtsev June 19, 2013

Thanks for fast answer. I have another question:

when I catched exception what do I need to display this velocity?

Florin Manaila
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 19, 2013

The velocity context is a simple map of <String, Object> which you can create by yourself. If you'd like a "basic" velocity context with some common utilities pre-filled, you can use the static methods of JiraVelocityHelper or JiraVelocityUtils to create one.

Florin Manaila
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 19, 2013

It actually depends on where you are doing this. What is the feature that you're trying to implement?

Alexander Urzhumtsev June 19, 2013

I have issue listener and need display errors for users

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 19, 2013

Listeners do not have feedback mechanisms for users.

You need to change the process at the front end (i.e. the action lands at a different place from where Jira normally sends it), write data in the listener for something else to pick up later, or write the listener so that it pokes data at an alternative way of notifying a user that there has been an error (e.g. email)

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 19, 2013

I assume you mean you don't want to use email, and you don't want to write data to be picked up later in Jira.

That leaves you with changing the landing point of a process. To do this, you need to pull apart the core code that starts your process (for example, an issue transition), work out how it decides the end point, and change that. You'll then need to provide a screen for display, and your listener will have to write data somewhere so that the screen can display it.

This is quite hard and complex. I'd suggest that you tell us what your actual requirement is, as there may well be a better way to do it than "use a listener and wedge in feedback"

Alexander Urzhumtsev June 19, 2013

I need display velocity immediatly for user (don't email). Where to forward this action?

0 votes
Onkar Ahire
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 19, 2013
TAGS
AUG Leaders

Atlassian Community Events