error

package
v0.0.0-...-c3cd77f Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2023 License: Zlib Imports: 4 Imported by: 88

Documentation

Overview

Package error provides error/logging functions that can be used in conjuction with http.Handler.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteError

func WriteError(rw http.ResponseWriter, code int, message string, err error)

WriteError is a convenience function that creates a new HandlerError before calling writeErrorResponse. For use outside of the standard http handlers.

Types

type HandlerError

type HandlerError struct {
	StatusCode int
	Message    string
	Err        error
}

HandlerError represents an error raised inside a HTTP handler

func BadRequest

func BadRequest(message string, err error) *HandlerError

func Forbidden

func Forbidden(message string, err error) *HandlerError

func InternalServerError

func InternalServerError(message string, err error) *HandlerError

func NewError

func NewError(statusCode int, message string, err error) *HandlerError

func NotFound

func NotFound(message string, err error) *HandlerError

func Unauthorized

func Unauthorized(message string, err error) *HandlerError

func (*HandlerError) Error

func (h *HandlerError) Error() string

type LoggerHandler

type LoggerHandler func(http.ResponseWriter, *http.Request) *HandlerError

LoggerHandler defines a HTTP handler that includes a HandlerError return pointer

func (LoggerHandler) ServeHTTP

func (handler LoggerHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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