errors

package
v0.0.0-...-45d3223 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package errors defines orchestration errors. This is following the patterns from https://blog.golang.org/go1.13-errors Error messages should contain a unique code easily parsable from string representation. Error IDs are 4 digit prefixed by "OE" (for Orchestration Error). Each error kind has 100 numbers reserved, here are the assigned ranges: - generic errors: 0-99 - asset related errors: 100-199

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrByteArray happens when attempting to load invalid data as json byte array
	ErrByteArray = "OE0001"

	// ErrNotFound happens when the asset is not present in the persistence layer
	ErrNotFound = "OE0002"

	// ErrBadRequest happens when the request can't be fulfilled
	ErrBadRequest = "OE0003"

	// ErrConflict is a sentinel value to mark conflicting asset errors.
	ErrConflict = "OE0006" // value 6 match gRPC AlreadyExists status code

	// ErrInternal happens when an unexpected error occurs (eg; unreachable code)
	ErrInternal = "OE0007"

	// ErrUnimplemented occurs when unimplemented code is triggered
	ErrUnimplemented = "OE0010"

	// ErrInvalidAsset marks asset validation errors
	ErrInvalidAsset = "OE0101"

	// ErrPermissionDenied happens when you try to perform an action on an asset
	// that you do not own.
	ErrPermissionDenied = "OE0102"

	// ErrIncompatibleTaskStatus occurs when a task cannot be processed due to its status
	ErrIncompatibleTaskStatus = "OE0104"

	// ErrCannotDisableModel occurs when attempting to disable a model that is not eligible
	ErrCannotDisableModel = "OE0105"

	// ErrMissingTaskOutput occurs when attempting to register an asset referencing a non-existing task output
	ErrMissingTaskOutput = "OE0106"

	// ErrIncompatibleKind occurs when attempting to register an asset for a task output of a different kind
	ErrIncompatibleKind = "OE0107"

	// ErrCannotDisableOutput occurs when attempting to disable an output that is not eligible
	ErrCannotDisableOutput = "OE0108"

	// ErrTerminatedComputePlan occurs when attempting to cancel or fail an already terminated compute plan
	ErrTerminatedComputePlan = "OE0109"

	// ErrTerminatedComputeTask occurs when attempting to cancel or fail an already terminated compute plan
	ErrTerminatedComputeTask = "OE0110"
)

Functions

This section is empty.

Types

type ErrorKind

type ErrorKind = string

ErrorKind is unique per kind of orchestration error. It may be used to determine response status.

type OrcError

type OrcError struct {
	Kind ErrorKind
	// contains filtered or unexported fields
}

OrcError represents an orchestration error. It may wrap another error and will always contain a specific error code.

func FromValidationError

func FromValidationError(resource string, err error) *OrcError

FromValidationError returns an OrcError with ErrInvalidAsset kind wrapping the underlying validation error

func NewBadRequest

func NewBadRequest(msg string) *OrcError

NewBadRequest returns an ErrBadRequest kind of OrcError with given message

func NewCannotDisableAsset

func NewCannotDisableAsset(msg string) *OrcError

NewCannotDisableAsset returns an ErrCannotDisableModel kind of OrcError with given message

func NewCannotDisableModel

func NewCannotDisableModel(msg string) *OrcError

NewCannotDisableModel returns an ErrCannotDisableModel kind of OrcError with given message

func NewConflict

func NewConflict(resource, key string) *OrcError

NewConflict returns an ErrConflict kind of OrcError with relevant message

func NewError

func NewError(kind ErrorKind, msg string) *OrcError

NewError creates an OrcError with given kind and message

func NewIncompatibleTaskOutput

func NewIncompatibleTaskOutput(taskKey, identifier, expected, actual string) *OrcError

func NewInternal

func NewInternal(msg string) *OrcError

NewInternal returns an ErrInternalError kind of OrcError with given message

func NewInvalidAsset

func NewInvalidAsset(msg string) *OrcError

NewInvalidAsset returns an ErrInvalidAsset kind of OrcError with given message

func NewMissingTaskOutput

func NewMissingTaskOutput(taskKey, identifier string) *OrcError

func NewNotFound

func NewNotFound(resource, key string) *OrcError

NewNotFound returns an ErrNotFound kind of OrcError with relevant message

func NewPermissionDenied

func NewPermissionDenied(msg string) *OrcError

NewPermissionDenied returns an ErrPermissionDenied kind of OrcError with given message

func NewTerminatedComputePlan

func NewTerminatedComputePlan(planKey string) *OrcError

NewTerminatedComputePlan returns an ErrTerminatedComputePlan kind of OrcError with given message

func NewTerminatedComputeTask

func NewTerminatedComputeTask(taskKey string) *OrcError

NewTerminatedComputeTask returns an ErrTerminatedComputeTask kind of OrcError with given message

func NewUnimplemented

func NewUnimplemented(msg string) *OrcError

NewUnimplemented returns an ErrUnimplemented kind of OrcError with given message

func (*OrcError) Error

func (e *OrcError) Error() string

Error returns the error message

func (*OrcError) Source

func (e *OrcError) Source() string

Source will return error's source as file:line

func (*OrcError) Unwrap

func (e *OrcError) Unwrap() error

Unwrap returns the wrapped error if any

func (*OrcError) Wrap

func (e *OrcError) Wrap(err error) *OrcError

Wrap make sure the given error is embedded in the error chain. It returns the OrcError for a convenient fluent interface.

Jump to

Keyboard shortcuts

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