dromara / dromara/forest

拦截器主动抛出异常为何还会执行后续的response.getResult()操作?

Open
#179 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.9k
Forks
241
PR merge metrics
No merged PRs in 30d

Description

![image](https://github.com/dromara/forest/assets/24694117/f6a58fa1-17ef-4041-8ded-8da4c3fdab71)
此处handleError的时候会出来响应码不为200的,并包装成网络错误
![image](https://github.com/dromara/forest/assets/24694117/5d66d72f-f194-4290-9b18-81b05e6a001d)
某个拦截器的onError方法主动抛出了自定义异常,会被最初的handleSyncWithException的catch (Throwable th)拦截。
此时为何又要去response.getResult()?
![image](https://github.com/dromara/forest/assets/24694117/988d5c7f-7d09-4070-ab6b-efb176006655)
![image](https://github.com/dromara/forest/assets/24694117/5e74b180-49c4-4682-a899-ccd9aaef9e15)
如果getResult一般会抛出数据转换异常,这样导致自定义拦截器中抛出的自定义异常丢失。
![image](https://github.com/dromara/forest/assets/24694117/024eb075-7ea7-4931-8d4f-8e9dd640692d)
![image](https://github.com/dromara/forest/assets/24694117/a00221d8-87ab-4bec-bbde-f37a167a1ced)
![image](https://github.com/dromara/forest/assets/24694117/77a069bd-5fda-4b93-9e60-95f3b4197eea)
这个如何解决?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing the exception flow through handleError, handleSyncWithException, the interceptor onError method, and response.getResult(). Reproduce a non-200 response where onError throws a custom exception, then verify that the custom exception is preserved and data conversion is not invoked afterward.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.