We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
我这边通过一个模板方式,对IM的所有接口进行了包装,如果方法显性的扔出IOException,代码不太优雅。 我目前是这样写的
TxClientTemplate.call(room.getConfigId(), (imClient) -> imClient.group.sendGroupMsg(request));
然后 TxClientTemplate.call 的代码是这样的
public static <T extends GenericResult> T call(Long configId, Function<ImClient, T> function) { ImClient imClient = CLIENTS.get(configId); if (imClient == null) { throw new RuntimeException("缺少" + configId + "的imClient的配置"); } try { T result = function.apply(imClient); log.info("请求腾讯云直播接口,响应:{}", JsonUtil.toJsonString(result)); if (!"OK".equals(result.getActionStatus()) || 0 != result.getErrorCode()) { log.error("请求腾讯云失败,状态非OK"); throw BizException.create("103", result.getErrorInfo()); } return result; } catch (Throwable throwable) { log.error("调用腾讯云发生异常,错误信息:{}", ExceptionUtil.getMessage(throwable), throwable); throw BizException.create("103", "调用腾讯云接口失败"); } }
如果显性的有IOException,那我的代码就需要每个都需要 try - catch 了就变成了,感觉很不优雅。
TxClientTemplate.call(room.getConfigId(), (imClient) -> { try { return imClient.group.sendGroupMsg(request); } catch (IOException e) { throw new RuntimeException(e); } });
The text was updated successfully, but these errors were encountered:
这个问题不大 打个@SneakyThrows就行了.
Sorry, something went wrong.
No branches or pull requests
我这边通过一个模板方式,对IM的所有接口进行了包装,如果方法显性的扔出IOException,代码不太优雅。
我目前是这样写的
然后 TxClientTemplate.call 的代码是这样的
如果显性的有IOException,那我的代码就需要每个都需要 try - catch 了就变成了,感觉很不优雅。
The text was updated successfully, but these errors were encountered: