api

package
v2.3.19 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSiteMissing         = Error{ErrorCode: "SITE_MISSING", ErrorDescription: "missing site"}
	ErrUnknown             = Error{ErrorCode: "UNKNOWN_ERROR", ErrorDescription: "error is unknown"}
	ErrInternalServerError = Error{ErrorCode: "INTERNAL_SERVER_ERROR", ErrorDescription: "internal server error"}
)

Functions

func LogHttpError added in v2.3.18

func LogHttpError(logger *logrus.Entry, path string, code int, err error)

LogHttpError logs errors with a different log level depending on the http status code.

Types

type Error

type Error struct {
	ErrorCode        string                  `json:"errorCode"`
	ErrorDescription string                  `json:"errorDescription"`
	Field            *string                 `json:"field,omitempty"`
	Info             *map[string]interface{} `json:"info,omitempty"`
}

func (Error) Error

func (e Error) Error() string

func (Error) ToErrorResponse

func (e Error) ToErrorResponse() ErrorResponse

type ErrorHandler added in v2.3.18

type ErrorHandler[E error] struct {
	NewUnknownError func(msg string) E
	NewTimeoutError func(msg string) E
	HttpStatusFrom  func(ctx context.Context, err error) int
	ToApiError      func(err error) error
}

func (*ErrorHandler[E]) HandleError added in v2.3.18

func (eh *ErrorHandler[E]) HandleError(ctx context.Context, c echo.Context, err error)

type ErrorResponse

type ErrorResponse struct {
	MainError Error   `json:"mainError"`
	AllErrors []Error `json:"allErrors"`
}

func NewErrorResponse

func NewErrorResponse(errorCode string, errorDescription string, field string, info map[string]interface{}) ErrorResponse

func (ErrorResponse) Error

func (e ErrorResponse) Error() string

type SiteId

type SiteId string

func GetSiteFromHeader

func GetSiteFromHeader(header http.Header) (SiteId, error)

func (SiteId) ToLower

func (s SiteId) ToLower() SiteId

func (SiteId) ToUpper

func (s SiteId) ToUpper() SiteId

Jump to

Keyboard shortcuts

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