How to use @ControllerAdvice for Jira Plugin Development?

thien dinh ngoc November 1, 2019

I am developing the Jira plugin using Atlassian SDK

I want to create the controller advice to handle exception, but is is not working. How can I make the controller advice work? Here is my source code

import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

@ControllerAdvice("com.jira.plugin.test")
public class ServiceErrorAdvice {

  @ExceptionHandler({ServiceException.class})
  public ResponseEntity<String> handleRunTimeException(ServiceException e) {
    return error(INTERNAL_SERVER_ERROR, e);
  }

  private ResponseEntity<String> error(HttpStatus status, Exception e) {
    return ResponseEntity.status(status).body(e.getMessage());
  }
}

 

1 answer

0 votes
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 6, 2019

Hi @thien dinh ngoc ,

Welcome to the Atlassian Community!

 

Please notice that this is not the best place to get help on apps/add-on development  related questions. 

In case you won't manage any answer in here, you might want to refer to the resources listed in https://developer.atlassian.com/resources. 

Specifically:

 

Cheers,
Dario

Suggest an answer

Log in or Sign up to answer