api

package
v0.5.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ErrorCodeInternalError          = "INTERNAL_ERROR"
	ErrorCodeTemporarilyUnavailable = "TEMPORARILY_UNAVAILABLE"
	ErrorCodeBadRequest             = "BAD_REQUEST"
	ErrorCodeInvalidParameterValue  = "INVALID_PARAMETER_VALUE"
	ErrorCodeEndpointNotFound       = "ENDPOINT_NOT_FOUND"
	ErrorCodeResourceAlreadyExists  = "RESOURCE_ALREADY_EXISTS"
	ErrorCodeResourceDoesNotExist   = "RESOURCE_DOES_NOT_EXIST"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorCode

type ErrorCode string

type ErrorResponse

type ErrorResponse struct {
	Message       string    `json:"message"`
	ErrorCode     ErrorCode `json:"error_code"`
	StatusCode    int       `json:"-"`
	OriginalError error     `json:"-"`
}

ErrorResponse represents error response object.

func NewBadRequestError

func NewBadRequestError(msg string, args ...any) *ErrorResponse

NewBadRequestError creates new Response object with ErrorCodeBadRequest.

func NewEndpointNotFound

func NewEndpointNotFound(msg string, args ...any) *ErrorResponse

NewEndpointNotFound creates new Response object with ErrorCodeEndpointNotFound.

func NewInternalError

func NewInternalError(msg string, args ...any) *ErrorResponse

NewInternalError creates new Response object with ErrorCodeInternalError.

func NewInvalidParameterValueError

func NewInvalidParameterValueError(msg string, args ...any) *ErrorResponse

NewInvalidParameterValueError creates new Response object with ErrorCodeInternalError.

func NewResourceAlreadyExistsError

func NewResourceAlreadyExistsError(msg string, args ...any) *ErrorResponse

NewResourceAlreadyExistsError creates new Response object with ErrorCodeResourceAlreadyExists.

func NewResourceDoesNotExistError

func NewResourceDoesNotExistError(msg string, args ...any) *ErrorResponse

NewResourceDoesNotExistError creates new Response object with ErrorCodeResourceDoesNotExist.

func (*ErrorResponse) Error

func (e *ErrorResponse) Error() string

Error provides error interface to be compatible with std errors.

func (*ErrorResponse) WithError

func (e *ErrorResponse) WithError(err error)

WithError stores the original error which actually caused the problem.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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