问题描述
我正在尝试捕获在我的 streamingresponsebody
实现中抛出的异常,我可以看到类中抛出的异常但是我处理的抛出的异常似乎有效,但我无法获得我的自定义消息,我的响应代码是 200
。
@GetMapping(path = "/test",produces = "application/json")
public streamingresponsebody test(@RequestParam(value = "var1") final String test) throws IOException{
return new streamingresponsebody() {
@Override
public void writeto(final OutputStream outputStream) throws IOException{
try {
// Some operations..
} catch (Exception MyExceptione e) {
throw new MyException(e);
}
}
};
}
@ExceptionHandler(MyException.class)
public ResponseEntity handleMyException(MyException exception) {
return ResponseEntity.status(exception.getHttpStatus()).body(
ErrorDTO.builder()
.message(exception.getMessage())
.description(exception.getHttpStatus().getReasonPhrase())
.build());
}
我希望我的 ControllerAdvice
返回一个 ResponseEntity
,Http Status
为 500。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)