response

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// 400 errors
	ErrBadRequest = Error{
		StatusCode: http.StatusBadRequest,
		Err:        "The request was malformed or missing required parameters.",
		Type:       gin.ErrorTypePublic,
	}

	ErrUnauthorized = Error{
		StatusCode: http.StatusUnauthorized,
		Err:        "Authentication token is missing or is invalid.",
		Type:       gin.ErrorTypePublic,
	}

	ErrForbidden = Error{
		StatusCode: http.StatusForbidden,
		Err:        "Access Denied: You do not have permission to access this resource.",
		Type:       gin.ErrorTypePublic,
	}

	ErrNotFound = Error{
		StatusCode: http.StatusNotFound,
		Err:        "Requested resource not found on the server.",
		Type:       gin.ErrorTypePublic,
	}

	// 500 errors
	ErrInternalServerError = Error{
		StatusCode: http.StatusInternalServerError,
	}
)

Functions

This section is empty.

Types

type Error

type Error struct {
	StatusCode int
	Err        string
	Details    interface{}
	Type       gin.ErrorType
}

func (Error) Error

func (err Error) Error() string

func (Error) WithDetails

func (err Error) WithDetails(details interface{}) Error

type ErrorResponse

type ErrorResponse struct {
	Error   string          `json:"error"`
	Code    int             `json:"code"`
	Details json.RawMessage `json:"details,omitempty"`
	ErrorID uuid.UUID       `json:"error_id"`
}

Jump to

Keyboard shortcuts

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