我有一个 apache Camel Rest api,它从 S3 下载文件。我发送 json 输入(key, bucketname, accessKey, secretKey, region)
以便写入 URI。代码如下所示:
public static class HelloRoute extends RouteBuilder {
@Override
public void configure() {
rest("/")
.post("file-from-s3")
.route()
.setHeader(AWS2S3Constants.KEY, key)
.to("aws2-s3://bucketname?accessKey=INSERT&secretKey=INSERT®ion=INSERT&operation=getObject")
.endRest();
}
}
我可以通过使用在上面代码中提到的地方获取相应的 json 输入JSONObject
作为身体。
如果假设,我在 json 输入中输入了错误的值(例如 accessKey),我会收到类似的错误
The AWS Access Key Id you provided does not exist in our records. (Service: S3, Status Code: 403, Request ID: 6923BEC55C1FD5F1, Extended Request ID: re5Rb7I76j9jvGqhSQXgjUoMwOZqsprg22bOGD+BDbuj0zrRrf0FceLaapvpR4KcNDY6GntNiF0=)
这对用户来说不太友好。我如何为此编写一个自定义错误处理程序,它只会返回上述情况的错误消息,例如 Wrong Access Key