Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExceptionHandler 可以支持接口 #171

Open
TAKETODAY opened this issue Aug 12, 2022 · 0 comments
Open

ExceptionHandler 可以支持接口 #171

TAKETODAY opened this issue Aug 12, 2022 · 0 comments
Assignees
Labels
feature 新功能
Milestone

Comments

@TAKETODAY
Copy link
Owner

以下的实例比较局限

  @ExceptionHandler(NullPointerException.class)
  public Json nullPointer(NullPointerException exception) {
    log.error("Null Pointer occurred", exception);
    final StackTraceElement[] stackTrace = exception.getStackTrace();
    if (ObjectUtils.isNotEmpty(stackTrace)) {
      return Json.failed("空指针", stackTrace[0]);
    }
    return Json.failed("空指针", "暂无堆栈信息");
  }

如果可以直接声明接口,在多个异常实现了该接口之后就可以被处理

@TAKETODAY TAKETODAY added the feature 新功能 label Aug 12, 2022
@TAKETODAY TAKETODAY self-assigned this Aug 12, 2022
@TAKETODAY TAKETODAY added this to the 4.0 milestone Aug 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 新功能
Projects
Status: Todo
Development

No branches or pull requests

1 participant