errors

package
v0.0.0-...-ee63aef Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeInternalError = http.StatusInternalServerError
	CodeBadRequest    = http.StatusBadRequest
	CodeNotFound      = http.StatusNotFound
	CodeConflict      = http.StatusConflict
)

Common error codes

Variables

View Source
var (
	ErrInternalError = New(CodeInternalError, "Internal server error")
	ErrBadRequest    = New(CodeBadRequest, "Bad request")
	ErrNotFound      = New(CodeNotFound, "Resource not found")
	ErrConflict      = New(CodeConflict, "Resource conflict")
)

Common error messages

Functions

This section is empty.

Types

type Error

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

Error represents a common error type

func New

func New(code int, message string) *Error

New creates a new error with the given code and message

func Newf

func Newf(code int, format string, args ...interface{}) *Error

Newf creates a new error with the given code and formatted message

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface

Jump to

Keyboard shortcuts

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