errors

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BAD_REQUEST_ERROR = []ErrorContent{
		{
			Status: http.StatusBadRequest,
			Title:  "Bad Request",
		},
	}

	NOT_FOUND_ERROR = []ErrorContent{
		{
			Status: http.StatusNotFound,
			Title:  "Not Found",
		},
	}

	METHOD_NOT_ALLOWED_ERROR = []ErrorContent{
		{
			Status: http.StatusMethodNotAllowed,
			Title:  "Method Not Allowed",
		},
	}

	UNSUPPORTED_MEDIA_TYPE_ERROR = []ErrorContent{
		{
			Status: http.StatusUnsupportedMediaType,
			Title:  "Unsupported Media Type",
		},
	}

	INTERNAL_SERVER_ERROR = []ErrorContent{
		{
			Status: http.StatusInternalServerError,
			Title:  "Internal Server Error",
		},
	}
)

Functions

This section is empty.

Types

type ErrorContent

type ErrorContent struct {
	Status int    `json:"status"`
	Title  string `json:"title"`
	Detail string `json:"detail,omitempty"`
}

type HTTPError

type HTTPError struct {
	Status int          `json:"-"`
	Header *http.Header `json:"-"`

	Errors *[]ErrorContent `json:"errors"`
}

func NewHTTPError

func NewHTTPError(status int, errors *[]ErrorContent) *HTTPError

func (*HTTPError) Error

func (e *HTTPError) Error() string

func (*HTTPError) SetHeader

func (e *HTTPError) SetHeader(key, value string)

func (*HTTPError) Write

func (e *HTTPError) Write(w http.ResponseWriter)

Jump to

Keyboard shortcuts

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