我应该使用org.springframework.security.access.AccessDeniedException作为参数创建一个额外的方法吗?
@ControllerAdvice
public class AccessDeniedExceptionAdvice {
private final Logger log = LoggerFactory.getLogger(getClass());
@Autowired
private ErrorResponseMapperService errorResponseMapper;
@ExceptionHandler({ com.mycomp.myapp.platform.common.exception.AccessDeniedException.class
, org.springframework.security.access.AccessDeniedException.class }) // <-- Here i have added an extra exeption
@ResponseStatus(value = HttpStatus.FORBIDDEN)
@ResponseBody
public ErrorResponseDto accessDenied(com.mycomp.myapp.platform.common.exception.AccessDeniedException.class ex) {
log.error("Access denied", ex);
return errorResponseMapper.createErrorReponseDto(null, "Access Denied",
MyAppErrorCodesEnumDto.MY_APP_UNAUTHORIZED_EXCEPTION);
}
}