weberrors

Imports

Imports #

"encoding/json"
"errors"
"log"
"net/http"

Structs

AoCError struct #

Error sent by application for web responses, API responses

type AoCError struct {
ErrorCode int `json:"errorcode"`
ErrorMessage string `json:"errormessage"`
}

Functions

HandleError function #

Handles errors - write response code and encapsulates err msg into json

func HandleError(w http.ResponseWriter, logger *log.Logger, err error, httpErrorCode int, errMsg string) error

NewError function #

Constructor

func NewError(status int, message string) AoCError

OkToError function #

Helper function - converts bool to error true -> nil false -> generic error

func OkToError(ok bool) error