errors

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 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 checks if access is denied

func IsBucketExists

func IsBucketExists(err error) bool

IsBucketExists checks if the bucket already exists

func IsBucketNotEmpty

func IsBucketNotEmpty(err error) bool

IsBucketNotEmpty checks if the bucket is not empty

func IsBucketNotFound

func IsBucketNotFound(err error) bool

IsBucketNotFound checks if the bucket does not exist

func IsInvalidArgument

func IsInvalidArgument(err error) bool

IsInvalidArgument checks if the error is due to an invalid argument

func IsNotFound

func IsNotFound(err error) bool

IsNotFound checks if the error indicates that a resource was not found

func IsObjectNotFound

func IsObjectNotFound(err error) bool

IsObjectNotFound checks if the object does not exist

func IsRetryable

func IsRetryable(err error) bool

IsRetryable checks if the error is retryable

func IsServiceUnavailable

func IsServiceUnavailable(err error) bool

IsServiceUnavailable checks if the service is unavailable

func ParseErrorResponse

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

ParseErrorResponse parses an error response from the server

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 error

func NewAPIError

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

NewAPIError creates a new APIError

func ToAPIError

func ToAPIError(err error) *APIError

ToAPIError converts a generic error to an APIError if possible

func (*APIError) Code

func (e *APIError) Code() RustfsGoErrorCode

Code returns the error code

func (*APIError) Error

func (e *APIError) Error() string

Error implements the error interface

func (*APIError) Message

func (e *APIError) Message() string

Message returns the error message

func (*APIError) RequestID

func (e *APIError) RequestID() string

RequestID returns the request ID

func (*APIError) Resource

func (e *APIError) Resource() string

Resource returns the resource

func (*APIError) StatusCode

func (e *APIError) StatusCode() int

StatusCode returns the HTTP status code

func (*APIError) WithRegion

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

WithRegion sets the region

func (*APIError) WithRequestID

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

WithRequestID sets the request ID

func (*APIError) WithResource

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

WithResource sets the resource

type Error

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

Error RustFSGo error interface

type RustfsGoErrorCode

type RustfsGoErrorCode string

RustfsGoErrorCode defines RustfsGo error codes

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

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

	// access
	ErrCodeAccessDenied          RustfsGoErrorCode = "AccessDenied"
	ErrCodeAccountProblem        RustfsGoErrorCode = "AccountProblem"
	ErrCodeInvalidAccessKeyId    RustfsGoErrorCode = "InvalidAccessKeyId"
	ErrCodeSignatureDoesNotMatch RustfsGoErrorCode = "SignatureDoesNotMatch"

	// request
	ErrCodeInvalidArgument      RustfsGoErrorCode = "InvalidArgument"
	ErrCodeInvalidRequest       RustfsGoErrorCode = "InvalidRequest"
	ErrCodeMalformedXML         RustfsGoErrorCode = "MalformedXML"
	ErrCodeMissingContentLength RustfsGoErrorCode = "MissingContentLength"
	ErrCodeMethodNotAllowed     RustfsGoErrorCode = "MethodNotAllowed"
	ErrNilResponse              RustfsGoErrorCode = "NilResponse"
	ErrRequestTimeout           RustfsGoErrorCode = "RequestTimeout"
	ErrRequestTimeTooSkewed     RustfsGoErrorCode = "RequestTimeTooSkewed"
	ErrMovedPermanently         RustfsGoErrorCode = "MovedPermanently"
	ErrConflict                 RustfsGoErrorCode = "Conflict"
	ErrInvalidRange             RustfsGoErrorCode = "InvalidRange"

	// region and authorization
	ErrCodeInvalidRegion                RustfsGoErrorCode = "InvalidRegion"
	ErrCodeAuthorizationHeaderMalformed RustfsGoErrorCode = "AuthorizationHeaderMalformed"

	// server
	ErrCodeInternalError      RustfsGoErrorCode = "InternalError"
	ErrCodeServiceUnavailable RustfsGoErrorCode = "ServiceUnavailable"
	ErrCodeSlowDown           RustfsGoErrorCode = "SlowDown"
	ErrCodeNotImplemented     RustfsGoErrorCode = "NotImplemented"

	// preconditions
	ErrCodePreconditionFailed RustfsGoErrorCode = "PreconditionFailed"
	ErrCodeNotModified        RustfsGoErrorCode = "NotModified"

	// copy
	ErrCodeInvalidCopySource RustfsGoErrorCode = "InvalidCopySource"
)

S3 standard error codes

func (RustfsGoErrorCode) Error

func (e RustfsGoErrorCode) Error() string

Error implements the error interface for RustfsGoErrorCode

Jump to

Keyboard shortcuts

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