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


I created a project template plugin, according to the tutorial here:
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.

 public ConfigureResponse configure(final ConfigureData configureData)

 try {
 } 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!


Looking at the javadocs: https://docs.atlassian.com/software/jira/docs/api/7.6.1/com/atlassian/jira/project/template/hook/AddProjectHook.html

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 https://docs.atlassian.com/software/jira/docs/api/7.6.1/com/atlassian/jira/project/ProjectPropertiesManager.html ). 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


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