apierrors

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Generic Error Descriptions
	ErrorDescriptionInternalError = "Failed to process the request due to an internal error."
	ErrorDescriptionNotFound      = "The requested resource does not exist."
	ErrorDescriptionConflict      = "" /* 188-byte string literal not displayed */

	// Validation Error Descriptions
	ErrorDescriptionMalformedRequest  = "Unable to process request due to a malformed or invalid request body or query parameter."
	ErrorDescriptionMissingParameters = "Unable to process request due to missing required parameters in the request body or query parameters."
	ErrorDescriptionInvalidTimeFormat = "Invalid time format in request body."

	// Bundle Error Descriptions
	ErrorDescriptionBundleTitleAlreadyExist = "A bundle with the same title already exists."

	// State Error Descriptions
	ErrorDescriptionInvalidStateTransition      = "Unable to process request due to invalid state transition."
	ErrorDescriptionStateNotAllowedToTransition = "state not allowed to transition."

	// Header Error Descriptions
	ErrorDescriptionMissingIfMatchHeader = "Unable to process request due to missing If-Match header."
	ErrorDescriptionInvalidIfMatchHeader = "Unable to process request invalid If-Match header."

	// Auth Error Descriptions
	ErrorDescriptionAccessDenied = "Access denied."

	// Scheduling Error Descriptions
	ErrorDescriptionScheduledAtIsInPast       = "scheduled_at cannot be in the past."
	ErrorDescriptionScheduledAtShouldNotBeSet = "scheduled_at should not be set for manual bundles."
	ErrorDescriptionScheduledAtIsRequired     = "scheduled_at is required for scheduled bundles."

	// Marshal/Unmarshal Error Descriptions
	ErrorDescriptionMarshalJSONObject = "Failed to Marshal bundle resource into bytes."
)

Response error descriptions

Variables

View Source
var (
	// Generic Errors
	ErrInternalServer = errors.New("internal error")
	ErrInvalidBody    = errors.New("invalid request body")
	ErrNotFound       = errors.New("not found")
	ErrUnauthorised   = errors.New("unauthorised access to API")

	// Bundle-Specific
	ErrBundleNotFound           = errors.New("bundle not found")
	ErrDeleteBundleForbidden    = errors.New("cannot delete a published bundle")
	ErrBundleAlreadyExists      = errors.New("bundle already exists")
	ErrBundleTitleAlreadyExists = errors.New("bundle with the same title already exists")
	ErrInvalidBundleState       = errors.New("invalid bundle state")
	ErrMissingBundleID          = errors.New("missing bundle ID")
	ErrInvalidBundleReference   = errors.New("invalid bundle reference")
	ErrBundleEventNotFound      = errors.New("bundle event not found")
	ErrBundleHasNoContentItems  = errors.New("bundle has no content items")

	// Content-Specific
	ErrContentItemNotFound = errors.New("content item not found")

	// Validation
	ErrMissingParameters      = errors.New("missing required parameters in request")
	ErrInvalidQueryParameter  = errors.New("invalid query parameter")
	ErrTooManyQueryParameters = errors.New("too many query parameters provided")

	// State errors
	ErrExpectedStateOfCreated  = errors.New("expected bundle state to be 'CREATED'")
	ErrExpectedStateOfApproved = errors.New("expected bundle state to be 'APPROVED'")
	ErrInvalidTransition       = errors.New("state not allowed to transition")
	ErrVersionStateNotApproved = errors.New("version state expected to be APPROVED when transitioning bundle to PUBLISHED")

	// Parsing errors
	ErrUnableToParseTime = errors.New("failed to parse time from json body")
	ErrUnableToParseJSON = errors.New("failed to parse json body")

	// Header errors
	ErrMissingIfMatchHeader = errors.New("missing If-Match header")
	ErrInvalidIfMatchHeader = errors.New("etag does not match")

	// Scheduling errors
	ErrScheduledAtRequired = errors.New("scheduled_at is required for scheduled bundles")
	ErrScheduledAtSet      = errors.New("scheduled_at should not be set for manual bundles")
	ErrScheduledAtInPast   = errors.New("scheduled_at cannot be in the past")

	// Other errors
	ErrUnableToReadMessage = errors.New("failed to read message body")
)

Core errors for dis-bundle-api

Map errors to HTTP status codes

Functions

func GetStatusCodeForErr added in v1.4.0

func GetStatusCodeForErr(err error) int

Types

type ErrInvalidPatch

type ErrInvalidPatch struct {
	Msg string
}

Custom error types for common HTTP cases

func (ErrInvalidPatch) Error

func (e ErrInvalidPatch) Error() string

Jump to

Keyboard shortcuts

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