Edge's 490 exception is thrown and can be used for business processing#2154
Edge's 490 exception is thrown and can be used for business processing#2154liuguangrong wants to merge 4 commits intoapache:masterfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2154 +/- ##
============================================
- Coverage 80.76% 80.75% -0.02%
Complexity 1339 1339
============================================
Files 1463 1463
Lines 40142 40147 +5
Branches 3411 3411
============================================
- Hits 32420 32419 -1
- Misses 6255 6261 +6
Partials 1467 1467
Continue to review full report at Codecov.
|
| .error(LOGGER, "Failed to send request, alreadyFailed:{}, local:{}, remote:{}, message={}.", | ||
| alreadyFailed, getLocalAddress(), ipPort.getSocketAddress(), | ||
| ExceptionUtils.getExceptionMessageWithoutTrace(e)); | ||
| httpRestClientInvocationHooks.forEach(httpServerExceptionHandler -> { |
There was a problem hiding this comment.
Maybe you can add a custom handler to fillful your requirements.
e.g. 'MyHandler implements Handler'
servicecomb.handler.chain.Consumer.defaut: your_current_handlers,myhandler
myhandler can process the exception thrown in RestClientInvocation
There was a problem hiding this comment.
https://docs.servicecomb.io/java-chassis/zh_CN/references-handlers/intruduction/
I found it didn't meet my requirements through experiments.
My handler executes before the exception is returned, and does not return to handler after the exception is thrown.
I can't get this exception message.
Is there any other way
There was a problem hiding this comment.
public class MyHandler implements Handler {
private static final Logger LOGGER = LoggerFactory.getLogger(MyHandler.class);
@Override
public void handle(Invocation invocation, AsyncResponse asyncResp) throws Exception {
LOGGER.info("before");
invocation.next(response -> {
LOGGER.info("after");
});
}
}
You can find many Handler implementations in servicecomb-java-chassis project.
|
I think the handler example given by @liubao68 cannot meet @liuguangrong 's needs. Because the transportHandler is the last handler in the source code. public class ConsumerHandlerManager extends AbstractHandlerManager {
@Override
protected String getName() {
return "Consumer";
}
@Override
protected String getInnerDefaultChainDef() {
return "simpleLB";
}
@Override
protected Handler getLastHandler() {
return TransportClientHandler.INSTANCE;
}
}and in private List<Handler> createHandlerChain(String chainDef) {
List<Class<Handler>> chainClasses = convertToChainClass(chainDef);
List<Handler> handlerList = new ArrayList<>();
for (Class<Handler> cls : chainClasses) {
try {
handlerList.add(cls.newInstance());
} catch (Exception e) {
// 在启动阶段直接抛异常出来
throw new Error(e);
}
}
handlerList.add(getLastHandler());
return handlerList;
}In addition, when the transportHandler calls an exception, it will return the exception information to the caller. Can the exception information be handled by the caller? Hope you provide the calling way and error message stack. |
|
This handler throw exception , will hanldled in code block |
|
Sorry, maybe we can got the answer from line 86, 125, 544 in InvokerUtils.reactiveInvoke("pojo", "InvokerEndpoint", "model", args, ClientModel.class, response -> {
if (response.isFailed()) {
// do something
}
});Is this okay? |
Follow this checklist to help us incorporate your contribution quickly and easily:
[SCB-XXX] Fixes bug in ApproximateQuantiles, where you replaceSCB-XXXwith the appropriate JIRA issue.mvn clean install -Pitto make sure basic checks pass. A more thorough check will be performed on your pull request automatically.