omeh

package module
v0.0.0-...-aff50f1 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2021 License: MIT Imports: 5 Imported by: 2

README

Godoc license

omeh - One more error handler

Handle and return unique errors that can be searched quickly to find the exact error.

Allows you to return unique errors to the UI that can be quickly found in a sea of logs with the exact location and details where the error occured.

image
[Example App] ErrorHandler: 2021/06/09 19:47:07 
  -- Function: main.(*App).brokenRoute
  -- SourceFile: /Users/user/Development/go/omeh/example/routes.go
  -- LineNumber: 36
  -- ErrorDetails: did something and it broke
  -- RequestDetail: /broken
  -- ErrorCode: 5000732679545666175

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NonUIError = &ErrResponse{StatusCode: 0, StatusText: "Server error!"}
View Source
var StatusBadRequest = &ErrResponse{StatusCode: 400, StatusText: "Status Bad Request"}
View Source
var StatusInternalServerError = &ErrResponse{StatusCode: 500, StatusText: "Status Internal Server Error"}
View Source
var StatusNotFound = &ErrResponse{StatusCode: 404, StatusText: "Status Not Found"}
View Source
var YouDoneMessedUpAARon = &ErrResponse{StatusCode: 500, StatusText: "You done messed up, A-A-Ron"}

Functions

This section is empty.

Types

type ErrManager

type ErrManager struct {
	ErrorHandler     processError
	LogError         handleErrorLog
	HandleHTTPErrors respondToError
	// contains filtered or unexported fields
}

func New

func New(d bool) *ErrManager

func (*ErrManager) ProcessErrorHTTP

func (e *ErrManager) ProcessErrorHTTP(h ErrorHandlerdesc) http.HandlerFunc

func (*ErrManager) ReturnError

func (e *ErrManager) ReturnError(err error, er *ErrResponse, requestDetails string) *ErrResponse

func (*ErrManager) SetDebug

func (e *ErrManager) SetDebug(d bool)

func (*ErrManager) SetDefaultHandler

func (e *ErrManager) SetDefaultHandler(def processError)

func (*ErrManager) SetErrorLogHandler

func (e *ErrManager) SetErrorLogHandler(handler handleErrorLog)

func (*ErrManager) SetHTTPErrorHandler

func (e *ErrManager) SetHTTPErrorHandler(handler respondToError)

type ErrResponse

type ErrResponse struct {
	// Internal Only
	Err           error   `json:"-"`
	RequestDetail string  `json:"-"`
	FuncPC        uintptr `json:"-"`
	FuncFN        string  `json:"-"`
	FuncLine      int     `json:"-"`

	// Public
	StatusCode int    `json:"-"`
	StatusText string `json:"status"`
	AppCode    int64  `json:"code,omitempty"`
}

type ErrorHandlerdesc

type ErrorHandlerdesc func(http.ResponseWriter, *http.Request) *ErrResponse

Directories

Path Synopsis
example module

Jump to

Keyboard shortcuts

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