JIRA project template - How to deal with exceptions in AddProjectHook?

Hello,

I created a project template plugin, according to the tutorial here:
https://developer.atlassian.com/server/jira/platform/creating-a-project-template/
It works fine! :slight_smile:

I’d like to catch exceptions in the configure method of my hook, and to display the error message on a screen.

 @Override
 public ConfigureResponse configure(final ConfigureData configureData)
 {

 try {
      myComponent.doStuff(configureData);
 
 } catch (CustomPluginException e) {
      // TO DO
      // send error message to Jira IHM?
 } 
 
 return ConfigureResponse.create();
 }

Is there any recommended way to do that?

Thanks in advance!

3 Likes

Looking at the javadocs: AddProjectHook (Atlassian JIRA 7.6.1 API)

At the point that configure() is called - the project has already been created. At that point there is nothing the user can do - that’s why they’re regardless of outcome - redirected to the project page.

My suggestion would be to either:
a) Move as much of your validation to the validate() method and have a web-panel on the project admin ui that validates the project as “sane” (according to your definition of “sane”).
b) In your CustomPluginException, store the exception as a property on the project (using ProjectPropertiesManager (Atlassian JIRA 7.6.1 API) ). Then have a web-panel that just checks the property to see if it exists. If it does exist - then grab the content and render it in a flag display (and clear out the property when the user dismisses it).

Hope that helps

2 Likes

Thank you Daniel,
I will check how the flag display works :slight_smile: