srverror

package
v0.0.0-...-876d392 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DEBUG = false

DEBUG is used to flag if the server errors are to respond with debug messages when handling http. Should be false when running during production

View Source
var LogPath = ""

LogPath is the directory to store all logs. This should be set externally

Functions

func LogString

func LogString(err error, req *http.Request, res http.ResponseWriter) string

LogString Returns a tab-indented human readable message containing information about the given error, request, and response

func WriteToFile

func WriteToFile(msg string) (err error)

WriteToFile writes the given message to the log directory specified by LogPath. The directory will have the structure of LogPath/YYYY/MM/DD.log

Types

type Error

type Error interface {
	error
	// normally only sends the first string in the messsages. In debug
	// mode sends the full Error message
	http.Handler
	Unwrap() error
	// creates new error with addition messages
	Extend(msgs ...string) Error
	Status() int
}

Error type that can also be used to handle http requests

func Basic

func Basic(status int, msgs ...string) Error

Basic creates a new instance of the server error without wrapping another error. See New

func New

func New(e error, status int, msgs ...string) Error

New creates a new instance of an Error wrapping the given error. status and msgs define what to respond to the request with.

Jump to

Keyboard shortcuts

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