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());
}
}