errors

package
v0.0.0-...-9d7e9a8 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2023 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDatabase = errors.New("Database error")

ErrDatabase is a generic database error

View Source
var ErrDatabaseNotFound = errors.New("Database not found")

ErrDatabaseNotFound is the error meant for when the database doesn't exist

View Source
var ErrDatabaseRelationNotFound = errors.New("Relation not found")

ErrDatabaseRelationNotFound is the error meant for when a table doesn't exist

View Source
var ErrMarshal = errors.New("Could not marshal struct into JSON")

ErrMarshal is the error thrown when marshalling fails

View Source
var ErrNotFound = &ErrorResponse{
	HTTPStatusCode: 404,
	Status:         "failure",
	Message:        "resource not found",
}

ErrNotFound is a predefined 404 error

Functions

func ErrInternalServer

func ErrInternalServer(err error) render.Renderer

ErrInternalServer returns a generic server error

func ErrInvalidRequest

func ErrInvalidRequest(err error) render.Renderer

ErrInvalidRequest indicates that the request was invalid

Types

type ErrorResponse

type ErrorResponse struct {
	Error          error  `json:"-"`               // low level runtime err
	HTTPStatusCode int    `json:"-"`               // http status code
	Message        string `json:"message"`         // high level status message
	Status         string `json:"status"`          // status message (success | failure)
	ErrorCode      int    `json:"code,omitempty"`  // application level error code
	ErrorText      string `json:"error,omitempty"` // application level error message
}

ErrorResponse represents the error response object

func (*ErrorResponse) Render

func (err *ErrorResponse) Render(w http.ResponseWriter, r *http.Request) error

Render is the error response renderer

Jump to

Keyboard shortcuts

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