frostfs-s3-gw/api/errors/errors.go
Alex Vanin 5d11d8f556 [#264] Remove minio code distributed with Apache 2.0 license
NeoFS S3 Gate based on Minio RELEASE.2020-07-02T00-15-09Z
code which distributed with Apache 2.0 license. This commit
removes remaining minio code with that license.

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2021-09-20 10:38:28 +03:00

46 lines
935 B
Go

package errors
import (
"fmt"
)
type (
// ErrorCode type of error status.
ErrorCode int
// Error structure represents API error.
Error struct {
ErrCode ErrorCode
Code string
Description string
HTTPStatusCode int
}
)
const maxEConfigJSONSize = 262272
// IsS3Error check if the provided error is a specific s3 error.
func IsS3Error(err error, code ErrorCode) bool {
e, ok := err.(Error)
return ok && e.ErrCode == code
}
func (e Error) Error() string {
return fmt.Sprintf("%s: %d => %s", e.Code, e.HTTPStatusCode, e.Description)
}
// ObjectError - error that linked to specific object.
type ObjectError struct {
Err error
Object string
Version string
}
func (e ObjectError) Error() string {
return fmt.Sprintf("%s (%s:%s)", e.Err, e.Object, e.Version)
}
// ObjectVersion get "object:version" string.
func (e ObjectError) ObjectVersion() string {
return e.Object + ":" + e.Version
}