error

package
v0.0.0-...-16c2cb2 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotImplemented = errors.New("this function is not implemented")

Functions

func HandleEchoError

func HandleEchoError(err error, c echo.Context)

Handles an error thrown by any echo context function This is used as echo.HTTPErrorHandler

func ToLogLevel

func ToLogLevel(level string) slog.Level

Returns the corresponding slog log level for the given string

Types

type ApiError

type ApiError struct {
	Status int    `json:"status"`
	Msg    string `json:"msg"`
}

API error struct

func ErrorInvalidRequest

func ErrorInvalidRequest(t string) ApiError

Returns an API error with a 400 status code and a message for type t

func ErrorNotFound

func ErrorNotFound(t string) ApiError

Returns an API error with a 404 status code and a message for type t

func NewApiUnimplementedError

func NewApiUnimplementedError() *ApiError

func NewClaimMissingError

func NewClaimMissingError(claim string) *ApiError

func NewDaoDbError

func NewDaoDbError() *ApiError

func NewDaoNotExistingError

func NewDaoNotExistingError(objectName, referenceKey string) *ApiError

func NewDaoReferenceError

func NewDaoReferenceError(referenceObjectName, referenceKey string) *ApiError

func NewDaoReferenceIdError

func NewDaoReferenceIdError(referenceObjectName string, id uint) *ApiError

func NewDaoReferenceTimedError

func NewDaoReferenceTimedError(referenceObjectName string, id uint, startValidity time.Time) *ApiError

func NewDaoReferenceVersionedError

func NewDaoReferenceVersionedError(referenceObjectName string, id, version uint) *ApiError

func NewDaoUnimplementedError

func NewDaoUnimplementedError() *ApiError

func NewDaoValidationError

func NewDaoValidationError(referenceObjectName, dataExpected, dataGot string) *ApiError

func NewUnauthorizedError

func NewUnauthorizedError(msg string) *ApiError

func (ApiError) Error

func (e ApiError) Error() string

Function to return the error message as string Implements the error interface

type ApiLogger

type ApiLogger struct {
	*slog.Logger
}

ApiLogger is a custom logger for the API

func NewApiLogger

func NewApiLogger(level string) *ApiLogger

Returns a new ApiLogger with the given log level

func (ApiLogger) Fatal

func (l ApiLogger) Fatal(msg string)

Create an error message that is fatal and exists the process

func (ApiLogger) HandleValues

HandleValues is a custom log handler for the echo logger middleware It handles the log values and logs them into the slog logger sink

Jump to

Keyboard shortcuts

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