errors

package
v0.0.0-...-be214e9 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Overview

Package errors provides definitions for some common errors that may be encountered through the course of the turning mission control's functions. These errors may be eventually mapped to HTTP error codes, when being returned as a response.

Index

Constants

View Source
const (
	// Unknown error type is used for all generic errors
	Unknown = ErrorType(iota)
	// BadInput is used when any function encounters bad/incomplete input
	BadInput
	// BadResponse is used when a go method or an external service returns bad data
	BadResponse
	// BadConfig is used when an initialization step fails due to missing / invalid config values
	BadConfig
	// NotFound is used when a resource cannot be located
	NotFound
	// TimeOut is used when a request / go routine times out
	TimeOut
)

Variables

This section is empty.

Functions

func GetErrorCode

func GetErrorCode(err error, p fiberProtocol.Protocol) int

GetErrorCode maps the ErrorType to http status codes and returns it

func Newf

func Newf(et ErrorType, msg string, args ...interface{}) error

Newf creates a new turingError of the specified type, with formatted message

func Wrapf

func Wrapf(err error, msg string, args ...interface{}) error

Wrapf creates a new wrapped turingError with formatted message

Types

type ErrorType

type ErrorType uint

ErrorType captures some common error types

func GetType

func GetType(err error) ErrorType

GetType returns the error type

func (ErrorType) Wrapf

func (errorType ErrorType) Wrapf(err error, msg string, args ...interface{}) error

Wrapf method creates a new wrapped turingError with formatted message, of the specified error type

type TuringError

type TuringError struct {
	Code    int
	Message string
}

TuringError associates an error message with a status code.

func NewTuringError

func NewTuringError(err error, protocol fiberProtocol.Protocol, code ...int) *TuringError

NewTuringError creates an error with a Status code

func (*TuringError) Error

func (e *TuringError) Error() string

Error satisfies the error interface

Jump to

Keyboard shortcuts

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