apierr

package
v0.40.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 13 Imported by: 28

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadRequest             = errors.New("the request is invalid")
	ErrUnauthenticated        = errors.New("the request does not have valid authentication (AuthN) credentials for the operation")
	ErrPermissionDenied       = errors.New("the caller does not have permission to execute the specified operation")
	ErrNotFound               = errors.New("the operation was performed on a resource that does not exist")
	ErrResourceConflict       = errors.New("maps to all HTTP 409 (Conflict) responses")
	ErrTooManyRequests        = errors.New("maps to HTTP code: 429 Too Many Requests")
	ErrCancelled              = errors.New("the operation was explicitly canceled by the caller")
	ErrInternalError          = errors.New("some invariants expected by the underlying system have been broken")
	ErrNotImplemented         = errors.New("the operation is not implemented or is not supported/enabled in this service")
	ErrTemporarilyUnavailable = errors.New("the service is currently unavailable")
	ErrDeadlineExceeded       = errors.New("the deadline expired before the operation could complete")
	ErrInvalidParameterValue  = inheritErr(ErrBadRequest, "supplied value for a parameter was invalid")
	ErrResourceDoesNotExist   = inheritErr(ErrNotFound, "operation was performed on a resource that does not exist")
	ErrAborted                = inheritErr(ErrResourceConflict, "the operation was aborted, typically due to a concurrency issue such as a sequencer check failure")
	ErrAlreadyExists          = inheritErr(ErrResourceConflict, "operation was rejected due a conflict with an existing resource")
	ErrResourceAlreadyExists  = inheritErr(ErrResourceConflict, "operation was rejected due a conflict with an existing resource")
	ErrResourceExhausted      = inheritErr(ErrTooManyRequests, "operation is rejected due to per-user rate limiting")
	ErrRequestLimitExceeded   = inheritErr(ErrTooManyRequests, "cluster request was rejected because it would exceed a resource limit")
	ErrUnknown                = inheritErr(ErrInternalError, "this error is used as a fallback if the platform-side mapping is missing some reason")
	ErrDataLoss               = inheritErr(ErrInternalError, "unrecoverable data loss or corruption")
)

Functions

func ByStatusCode added in v0.26.2

func ByStatusCode(statusCode int) (error, bool)

func GetAPIError added in v0.18.0

func GetAPIError(ctx context.Context, resp common.ResponseWrapper) error

GetAPIError inspects HTTP errors from the Databricks API for known transient errors.

func IsMissing

func IsMissing(err error) bool

IsMissing tells if error is about missing resource

func MakeUnexpectedError added in v0.29.0

func MakeUnexpectedError(resp *http.Response, err error, requestBody, responseBody []byte) error

Types

type APIError

type APIError struct {
	ErrorCode  string
	Message    string
	StatusCode int
	Details    []ErrorDetail
	// contains filtered or unexported fields
}

APIError is a generic struct for an api error on databricks

func GenericIOError added in v0.18.0

func GenericIOError(ue *url.Error) *APIError

func NotFound

func NotFound(message string) *APIError

NotFound returns properly formatted Not Found error

func ReadError added in v0.18.0

func ReadError(statusCode int, err error) *APIError

func TooManyRequests added in v0.18.0

func TooManyRequests() *APIError

func (*APIError) Error

func (apiError *APIError) Error() string

Error returns error message string instead of

func (*APIError) IsMissing

func (apiError *APIError) IsMissing() bool

IsMissing tells if it is missing resource

func (*APIError) IsRetriable

func (apiError *APIError) IsRetriable(ctx context.Context) bool

isRetriable returns true if error is retriable

func (*APIError) IsTooManyRequests

func (apiError *APIError) IsTooManyRequests() bool

IsTooManyRequests shows rate exceeded limits

func (*APIError) Unwrap added in v0.26.0

func (apiError *APIError) Unwrap() error

Unwrap error for easier client code checking

See https://pkg.go.dev/errors#example-Unwrap

type APIErrorBody

type APIErrorBody struct {
	ErrorCode string        `json:"error_code,omitempty"`
	Message   string        `json:"message,omitempty"`
	Details   []ErrorDetail `json:"details,omitempty"`
	// The following two are for scim api only
	// for RFC 7644 Section 3.7.3 https://tools.ietf.org/html/rfc7644#section-3.7.3
	ScimDetail string `json:"detail,omitempty"`
	ScimStatus string `json:"status,omitempty"`
	ScimType   string `json:"scimType,omitempty"`
	API12Error string `json:"error,omitempty"`
}

APIErrorBody maps "proper" databricks rest api errors to a struct

type ErrorDetail added in v0.20.0

type ErrorDetail struct {
	Type     string            `json:"@type,omitempty"`
	Reason   string            `json:"reason,omitempty"`
	Domain   string            `json:"domain,omitempty"`
	Metadata map[string]string `json:"metadata,omitempty"`
}

func GetErrorInfo added in v0.20.0

func GetErrorInfo(err error) []ErrorDetail

GetErrorInfo returns all entries in the list of error details of type `ErrorInfo`.

Jump to

Keyboard shortcuts

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