apierr

package
v0.66.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2025 License: Apache-2.0 Imports: 14 Imported by: 35

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")
	ErrInvalidState           = inheritErr(ErrBadRequest, "unexpected state")
	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 returns the API error from the response. If the response is not an error, it returns nil.

func IsMissing

func IsMissing(err error) bool

IsMissing tells if error is about missing resource

Types

type APIError

type APIError struct {
	ErrorCode  string
	Message    string
	StatusCode int

	// Details is the sublist of error details that can be unmarshalled into
	// the [ErrorDetail] type.
	//
	// Deprecated: Use [APIError.ErrorDetails] instead.
	Details []ErrorDetail
	// contains filtered or unexported fields
}

APIError represents a standard Databricks API error.

func (*APIError) Error

func (apiError *APIError) Error() string

Error returns the error message string.

func (*APIError) ErrorDetails added in v0.59.0

func (apiErr *APIError) ErrorDetails() ErrorDetails

ErrorDetails returns the error details of the APIError.

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 BadRequest added in v0.59.0

type BadRequest struct {
	FieldViolations []BadRequestFieldViolation
}

Describes violations in a client request. This error type focuses on the syntactic aspects of the request.

type BadRequestFieldViolation added in v0.59.0

type BadRequestFieldViolation struct {
	// A path leading to a field in the request body.
	Field string

	// A description of why the request element is bad.
	Description string
}

type DebugInfo added in v0.59.0

type DebugInfo struct {
	// The stack trace entries indicating where the error occurred.
	StackEntries []string

	// Additional debugging information provided by the server.
	Detail string
}

Describes additional debugging info.

type ErrorDetail deprecated 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"`
}

Deprecated: Use ErrorDetails instead.

func GetErrorInfo deprecated added in v0.20.0

func GetErrorInfo(err error) []ErrorDetail

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

Deprecated: Use APIError.ErrorDetails instead.

type ErrorDetails added in v0.59.0

type ErrorDetails struct {
	ErrorInfo           *ErrorInfo
	RequestInfo         *RequestInfo
	RetryInfo           *RetryInfo
	DebugInfo           *DebugInfo
	QuotaFailure        *QuotaFailure
	PreconditionFailure *PreconditionFailure
	BadRequest          *BadRequest
	ResourceInfo        *ResourceInfo
	Help                *Help

	// UnknownDetails contains error details that cannot be unmarshalled into
	// one of the known types above.
	UnknownDetails []any
}

ErrorDetails contains the error details of an API error. It is the union of known error details types and unknown details.

type ErrorInfo added in v0.59.0

type ErrorInfo struct {
	// The reason of the error. This is a constant value that identifies the
	// proximate cause of the error.
	Reason string

	// The logical grouping to which the "reason" belongs.
	Domain string

	// Additional structured details about this error.
	Metadata map[string]string
}

ErrorInfo describes the cause of the error with structured details.

type Help added in v0.59.0

type Help struct {
	// URL(s) pointing to additional information on handling the current error.
	Links []HelpLink
}

Provides links to documentation or for performing an out of band action.

For example, if a quota check failed with an error indicating the calling project hasn't enabled the accessed service, this can contain a URL pointing directly to the right place in the developer console to flip the bit.

type HelpLink struct {
	// Describes what the link offers.
	Description string

	// The URL of the link.
	URL string
}

type PreconditionFailure added in v0.59.0

type PreconditionFailure struct {
	// Describes all precondition violations.
	Violations []PreconditionFailureViolation
}

Describes what preconditions have failed.

type PreconditionFailureViolation added in v0.59.0

type PreconditionFailureViolation struct {
	// The type of PreconditionFailure.
	Type string

	// The subject, relative to the type, that failed.
	Subject string

	// A description of how the precondition failed. Developers can use this
	// description to understand how to fix the failure.
	//
	// For example: "Terms of service not accepted".
	Description string
}

type QuotaFailure added in v0.59.0

type QuotaFailure struct {
	// Describes all quota violations.
	Violations []QuotaFailureViolation
}

Describes how a quota check failed.

For example if a daily limit was exceeded for the calling project, a service could respond with a QuotaFailure detail containing the project id and the description of the quota limit that was exceeded. If the calling project hasn't enabled the service in the developer console, then a service could respond with the project id and set `service_disabled` to true.

Also see RetryInfo and Help types for other details about handling a quota failure.

type QuotaFailureViolation added in v0.59.0

type QuotaFailureViolation struct {
	// The subject on which the quota check failed.
	Subject string

	// A description of how the quota check failed. Clients can use this
	// description to find more about the quota configuration in the service's
	// public documentation, or find the relevant quota limit to adjust through
	// developer console.
	//
	// For example: "Service disabled" or "Daily Limit for read operations
	// exceeded".
	Description string
}

type RequestInfo added in v0.59.0

type RequestInfo struct {
	// An opaque string that should only be interpreted by the service that
	// generated it. For example, it can be used to identify requests in the
	// service's logs.
	RequestID string

	// Any data that was used to serve this request. For example, an encrypted
	// stack trace that can be sent back to the service provider for debugging.
	ServingData string
}

RequestInfo Contains metadata about the request that clients can attach when filing a bug or providing other forms of feedback.

type ResourceInfo added in v0.59.0

type ResourceInfo struct {
	// A name for the type of resource being accessed.
	ResourceType string

	// The name of the resource being accessed.
	ResourceName string

	// The owner of the resource (optional).
	Owner string

	// Describes what error is encountered when accessing this resource.
	Description string
}

Describes the resource that is being accessed.

type RetryInfo added in v0.59.0

type RetryInfo struct {
	// Clients should wait at least this long between retrying the same request.
	RetryDelay time.Duration
}

RetryInfo describes when the clients can retry a failed request. Clients could ignore the recommendation here or retry when this information is missing from error responses.

It's always recommended that clients should use exponential backoff when retrying.

Clients should wait until `retry_delay` amount of time has passed since receiving the error response before retrying. If retrying requests also fail, clients should use an exponential backoff scheme to gradually increase the delay between retries based on `retry_delay`, until either a maximum number of retries have been reached or a maximum retry delay cap has been reached.

Jump to

Keyboard shortcuts

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