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

优化错误提示 #105

Closed
longjuan opened this issue Dec 1, 2023 · 1 comment · Fixed by #113
Closed

优化错误提示 #105

longjuan opened this issue Dec 1, 2023 · 1 comment · Fixed by #113

Comments

@longjuan
Copy link
Member

longjuan commented Dec 1, 2023

目前,本插件遇到策略配置错误而导致对象存储返回403提示时,前端只会弹出服务器内部错误: 服务器内部发生错误,请稍候再试。,容易让用户认为是插件本身的问题。
image

因此打算当接收到对象存储的响应状态码时弹出接收到对象存储返回的错误状态码:xxx,请检查策略配置是否正确之类的提示。

@JohnNiang
Copy link
Member

Hi @longjuan,可以考虑使用 onErrorMap 方法重写错误信息,错误类型为 org.springframework.web.server.ServerWebInputException

    @Override
    public Mono<Attachment> upload(UploadContext uploadContext) {
        return Mono.just(uploadContext).filter(context -> this.shouldHandle(context.policy()))
            .flatMap(context -> {
                final var properties = getProperties(context.configMap());
                return upload(context, properties)
                    .subscribeOn(Schedulers.boundedElastic())
                    .map(objectDetail -> this.buildAttachment(properties, objectDetail))
+                   .onErrorMap();
            });
    }

f2c-ci-robot bot pushed a commit that referenced this issue Jan 16, 2024
```release-note
友好地提示异常信息
```
fixes #105

验证方法:
1. ak/sk乱输,发生接收到403状态码(接收错误状态码)
2. endpoint网址改成不存在的,如.com改成.comaaa(未知主机)
3. endpoint端口改成没监听的(超时)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants