- Restructure handlers into file_commands/file_queries/file_handlers - Add gRPC auth client, JWT middleware, rate limiting, request ID - Add common utilities: logger, sanitizer, s3_errors - Add unit tests for config, mediator, auth, request_id, sanitize - Add proto definitions and generated code - Remove old web UI pages - Add .dockerignore and .env.example
27 lines
470 B
Go
27 lines
470 B
Go
package common
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
|
|
"github.com/aws/aws-sdk-go-v2/service/s3/types"
|
|
)
|
|
|
|
func WrapS3Error(err error) error {
|
|
if err == nil {
|
|
return nil
|
|
}
|
|
|
|
var (
|
|
noSuchBucket *types.NoSuchBucket
|
|
noSuchKey *types.NoSuchKey
|
|
notFound *types.NotFound
|
|
)
|
|
|
|
if errors.As(err, &noSuchBucket) || errors.As(err, &noSuchKey) || errors.As(err, ¬Found) {
|
|
return NewNotFoundError("resource not found")
|
|
}
|
|
|
|
return fmt.Errorf("storage operation failed")
|
|
}
|