From 51904752ce8bcbe65d754d4d5c114116404bc440 Mon Sep 17 00:00:00 2001 From: Alan Protasio Date: Tue, 5 Sep 2023 18:24:33 -0700 Subject: [PATCH] Implementing ToErrorResponse method --- providers/s3/s3.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/providers/s3/s3.go b/providers/s3/s3.go index f92d3973..29a59945 100644 --- a/providers/s3/s3.go +++ b/providers/s3/s3.go @@ -638,3 +638,37 @@ func NewTestBucketFromConfig(t testing.TB, location string, c Config, reuseBucke func ContextWithSSEConfig(ctx context.Context, value encrypt.ServerSide) context.Context { return context.WithValue(ctx, sseConfigKey, value) } + +/* **** SAMPLE ERROR RESPONSE **** + + + AccessDenied + Access Denied + bucketName + objectName + F19772218238A85A + GuWkjyviSiGHizehqpmsD1ndz5NClSP19DOT+s2mv7gXGQ8/X1lhbDGiIJEXpGFD + +*/ + +type ErrorResponse struct { + Code string + Message string + BucketName string + Key string + RequestId string + HostId string +} + +// ToErrorResponse Returns parsed s3 ErrorResponse +func ToErrorResponse(err error) ErrorResponse { + er := minio.ToErrorResponse(errors.Cause(err)) + return ErrorResponse{ + Code: er.Code, + Message: er.Message, + BucketName: er.BucketName, + Key: er.Key, + RequestId: er.RequestID, + HostId: er.HostID, + } +}