errors

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package errors/check.go

Package errors/codes.go

Package errors/errors.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAccessDenied

func IsAccessDenied(err error) bool

IsAccessDenied 检查是否为访问拒绝错误

func IsBucketExists

func IsBucketExists(err error) bool

IsBucketExists 检查桶是否已存在

func IsBucketNotEmpty

func IsBucketNotEmpty(err error) bool

IsBucketNotEmpty 检查桶是否非空

func IsBucketNotFound

func IsBucketNotFound(err error) bool

IsBucketNotFound 检查桶是否不存在

func IsInvalidArgument

func IsInvalidArgument(err error) bool

IsInvalidArgument 检查是否为无效参数错误

func IsNotFound

func IsNotFound(err error) bool

IsNotFound 检查是否为未找到错误

func IsObjectNotFound

func IsObjectNotFound(err error) bool

IsObjectNotFound 检查对象是否不存在

func IsRetryable

func IsRetryable(err error) bool

IsRetryable 检查错误是否可重试

func IsServiceUnavailable

func IsServiceUnavailable(err error) bool

IsServiceUnavailable 检查服务是否不可用

func ParseErrorResponse

func ParseErrorResponse(resp *http.Response, bucketName, objectName string) error

ParseErrorResponse 从 HTTP 响应解析错误

Types

type APIError

type APIError struct {
	XMLName         xml.Name `xml:"Error"`
	ErrorCode       string   `xml:"Code"`
	ErrorMessage    string   `xml:"Message"`
	ErrorResource   string   `xml:"Resource"`
	ErrorRequestID  string   `xml:"RequestId"`
	HostID          string   `xml:"HostId"`
	ErrorStatusCode int      `xml:"-"`
	Region          string   `xml:"Region"`
}

APIError S3 API 错误

func NewAPIError

func NewAPIError(code RustfsGoErrorCode, message string, statusCode int) *APIError

NewAPIError 创建新的 API 错误

func ToAPIError

func ToAPIError(err error) *APIError

ToAPIError 将错误转换为 APIError

func (*APIError) Code

func (e *APIError) Code() RustfsGoErrorCode

Code 返回错误码

func (*APIError) Error

func (e *APIError) Error() string

Error 实现 error 接口

func (*APIError) Message

func (e *APIError) Message() string

Message 返回错误消息

func (*APIError) RequestID

func (e *APIError) RequestID() string

RequestID 返回请求 ID

func (*APIError) Resource

func (e *APIError) Resource() string

Resource 返回资源

func (*APIError) StatusCode

func (e *APIError) StatusCode() int

StatusCode 返回 HTTP 状态码

func (*APIError) WithRegion

func (e *APIError) WithRegion(region string) *APIError

WithRegion 设置区域

func (*APIError) WithRequestID

func (e *APIError) WithRequestID(id string) *APIError

WithRequestID 设置请求 ID

func (*APIError) WithResource

func (e *APIError) WithResource(resource string) *APIError

WithResource 设置资源

type Error

type Error interface {
	error
	Code() RustfsGoErrorCode
	Message() string
	StatusCode() int
	RequestID() string
	Resource() string
}

Error RustFS 错误接口

type RustfsGoErrorCode

type RustfsGoErrorCode string

RustfsGoErrorCode 定义了 RustfsGo 错误码的类型

const (
	// 桶相关
	ErrCodeNoSuchBucket            RustfsGoErrorCode = "NoSuchBucket"
	ErrCodeBucketAlreadyExists     RustfsGoErrorCode = "BucketAlreadyExists"
	ErrCodeBucketAlreadyOwnedByYou RustfsGoErrorCode = "BucketAlreadyOwnedByYou"
	ErrCodeBucketNotEmpty          RustfsGoErrorCode = "BucketNotEmpty"
	ErrCodeInvalidBucketName       RustfsGoErrorCode = "InvalidBucketName"

	// 对象相关
	ErrCodeNoSuchKey         RustfsGoErrorCode = "NoSuchKey"
	ErrCodeInvalidObjectName RustfsGoErrorCode = "XRustfsInvalidObjectName"
	ErrCodeNoSuchUpload      RustfsGoErrorCode = "NoSuchUpload"
	ErrCodeNoSuchVersion     RustfsGoErrorCode = "NoSuchVersion"
	ErrCodeInvalidPart       RustfsGoErrorCode = "InvalidPart"
	ErrCodeInvalidPartOrder  RustfsGoErrorCode = "InvalidPartOrder"
	ErrCodeEntityTooLarge    RustfsGoErrorCode = "EntityTooLarge"
	ErrCodeEntityTooSmall    RustfsGoErrorCode = "EntityTooSmall"

	// 访问控制
	ErrCodeAccessDenied          RustfsGoErrorCode = "AccessDenied"
	ErrCodeAccountProblem        RustfsGoErrorCode = "AccountProblem"
	ErrCodeInvalidAccessKeyId    RustfsGoErrorCode = "InvalidAccessKeyId"
	ErrCodeSignatureDoesNotMatch RustfsGoErrorCode = "SignatureDoesNotMatch"

	// 请求相关
	ErrCodeInvalidArgument      RustfsGoErrorCode = "InvalidArgument"
	ErrCodeInvalidRequest       RustfsGoErrorCode = "InvalidRequest"
	ErrCodeMalformedXML         RustfsGoErrorCode = "MalformedXML"
	ErrCodeMissingContentLength RustfsGoErrorCode = "MissingContentLength"
	ErrCodeMethodNotAllowed     RustfsGoErrorCode = "MethodNotAllowed"

	// 区域相关
	ErrCodeInvalidRegion                RustfsGoErrorCode = "InvalidRegion"
	ErrCodeAuthorizationHeaderMalformed RustfsGoErrorCode = "AuthorizationHeaderMalformed"

	// 服务器
	ErrCodeInternalError      RustfsGoErrorCode = "InternalError"
	ErrCodeServiceUnavailable RustfsGoErrorCode = "ServiceUnavailable"
	ErrCodeSlowDown           RustfsGoErrorCode = "SlowDown"
	ErrCodeNotImplemented     RustfsGoErrorCode = "NotImplemented"

	// 条件请求
	ErrCodePreconditionFailed RustfsGoErrorCode = "PreconditionFailed"
	ErrCodeNotModified        RustfsGoErrorCode = "NotModified"

	// 复制
	ErrCodeInvalidCopySource RustfsGoErrorCode = "InvalidCopySource"
)

S3 标准错误码

func (RustfsGoErrorCode) Error

func (e RustfsGoErrorCode) Error() string

Error 实现 error 接口

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL