errors

package
v1.2.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// GetAuthEntityDataErrorDescription auth entity data retrieval failures.
	GetAuthEntityDataErrorDescription = "failed to get auth entity data from request"
	// EntityDataErrorDescription describes entity data parsing failures.
	EntityDataErrorDescription = "unable to parse entity data from request context"
	// GetAuthEntityDataError identifies auth entity data retrieval failures.
	GetAuthEntityDataError = "GetAuthEntityDataError"
)

Variables

View Source
var (
	ErrJobNumberCounterNotFound     = errors.New("job number counter not found")
	ErrJobNotFound                  = errors.New("job not found")
	ErrUnableToParseBody            = errors.New("unable to read submitted body")
	ErrJobNumberNotProvided         = errors.New("job number not provided")
	ErrJobNumberMustBeInt           = errors.New("job number must be an integer")
	ErrSourceIDNotProvided          = errors.New("source ID not provided")
	ErrTargetIDNotProvided          = errors.New("target ID not provided")
	ErrJobTypeNotProvided           = errors.New("job type not provided")
	ErrSourceTitleNotFound          = errors.New("source title not found or empty")
	ErrSourceDoesNotExist           = errors.New("source ID does not exist")
	ErrTargetAlreadyExists          = errors.New("target ID already exists")
	ErrJobTypeInvalid               = errors.New("job type is invalid")
	ErrInternalServerError          = errors.New("an unexpected error occurred")
	ErrSourceIDValidation           = errors.New("source ID failed to validate")
	ErrTargetIDValidation           = errors.New("target ID failed to validate")
	ErrJobAlreadyRunning            = errors.New("job already running")
	ErrJobStateInvalid              = errors.New("job state parameter is invalid")
	ErrTaskStateInvalid             = errors.New("task state parameter is invalid")
	ErrJobStateNotAllowed           = errors.New("state not allowed for this endpoint")
	ErrJobStateTransitionNotAllowed = errors.New("state change is not allowed")
	ErrTaskNotFound                 = errors.New("task not found")
	ErrOffsetInvalid                = errors.New("offset parameter is invalid")
	ErrLimitInvalid                 = errors.New("limit parameter is invalid")
	ErrLimitExceeded                = errors.New("limit parameter exceeds maximum allowed")
	ErrUnauthorized                 = errors.New("unauthorized")
	ErrSortFieldInvalid             = errors.New("field is invalid in sort parameter")
	ErrSortDirectionInvalid         = errors.New("direction is invalid in sort parameter")

	ErrSourceIDZebedeeURIInvalid = errors.New("source ID URI path must start with '/', not end with '/', not contain query strings or hashbangs")
	ErrTargetIDDatasetIDInvalid  = errors.New("target id must be lowercase alphanumeric with optional hyphen separators")

	ErrSourceDataTypeInvalid         = errors.New("source data has incorrect type")
	ErrUnsupportedDistributionFormat = errors.New("unsupported mime type for distribution format")

	ErrFailedToUploadFileToUploadService = errors.New("failed to upload file to upload service")
	ErrInvalidTask                       = errors.New("invalid task or missing source/target information")

	ErrStateAlreadyAtTarget = errors.New("job is already in the target state")
	ErrStateUnexpected      = errors.New("job is in an unexpected state")

	ErrFailedToParseAuthEntityData = errors.New("failed to parse auth entity data")

	StatusCodeMap = map[error]int{
		ErrJobNotFound:                  http.StatusNotFound,
		ErrTaskNotFound:                 http.StatusNotFound,
		ErrUnableToParseBody:            http.StatusBadRequest,
		ErrJobNumberNotProvided:         http.StatusBadRequest,
		ErrJobNumberMustBeInt:           http.StatusBadRequest,
		ErrSourceIDNotProvided:          http.StatusBadRequest,
		ErrTargetIDNotProvided:          http.StatusBadRequest,
		ErrJobTypeNotProvided:           http.StatusBadRequest,
		ErrInternalServerError:          http.StatusInternalServerError,
		ErrSourceTitleNotFound:          http.StatusInternalServerError,
		ErrSourceIDValidation:           http.StatusInternalServerError,
		ErrTargetIDValidation:           http.StatusInternalServerError,
		ErrJobNumberCounterNotFound:     http.StatusInternalServerError,
		ErrJobAlreadyRunning:            http.StatusConflict,
		ErrSourceDoesNotExist:           http.StatusBadRequest,
		ErrTargetAlreadyExists:          http.StatusBadRequest,
		ErrSourceDataTypeInvalid:        http.StatusBadRequest,
		ErrJobTypeInvalid:               http.StatusBadRequest,
		ErrSourceIDZebedeeURIInvalid:    http.StatusBadRequest,
		ErrTargetIDDatasetIDInvalid:     http.StatusBadRequest,
		ErrJobStateInvalid:              http.StatusBadRequest,
		ErrTaskStateInvalid:             http.StatusBadRequest,
		ErrOffsetInvalid:                http.StatusBadRequest,
		ErrLimitInvalid:                 http.StatusBadRequest,
		ErrLimitExceeded:                http.StatusBadRequest,
		ErrJobStateTransitionNotAllowed: http.StatusConflict,
		ErrJobTypeInvalid:               http.StatusBadRequest,
		ErrJobStateNotAllowed:           http.StatusBadRequest,
		ErrSortFieldInvalid:             http.StatusBadRequest,
		ErrSortDirectionInvalid:         http.StatusBadRequest,
		ErrUnauthorized:                 http.StatusUnauthorized,
		ErrFailedToParseAuthEntityData:  http.StatusInternalServerError,
	}
)

Predefined errors

Functions

func NewAuditEventError added in v1.1.0

func NewAuditEventError(ctx context.Context, cause error, code, description string, logDatas ...log.Data)

NewAuditEventError creates and logs a new audit event error.

Types

type AuditEventError added in v1.1.0

type AuditEventError struct {
	Cause       error  `json:"-"`           // The underlying error, if available.
	Code        string `json:"code"`        // Error code representing the type of error.
	Description string `json:"description"` // Detailed description of the error.
}

AuditEventError represents an audit event error with context.

func (*AuditEventError) Error added in v1.1.0

func (e *AuditEventError) Error() string

Error returns the error message string for the custom Error type.

type Error

type Error struct {
	Code        int    `json:"code"`
	Description string `json:"description"`
}

Error represents a single error with a status code and description.

func New

func New(err error) Error

New creates a new redacted Error based on the provided error.

type ErrorList

type ErrorList struct {
	Errors []Error `json:"errors"`
}

ErrorList represents a list of errors.

type ErrorResponse added in v1.1.0

type ErrorResponse struct {
	Errors  []error           `json:"errors"`
	Status  int               `json:"-"`
	Headers map[string]string `json:"-"`
}

ErrorResponse represents a response containing one or more errors.

func NewErrorResponse added in v1.1.0

func NewErrorResponse(statusCode int, headers map[string]string, errs ...error) *ErrorResponse

NewErrorResponse a new ErrorResponse, status code, headers, and errors.

Jump to

Keyboard shortcuts

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