Documentation
¶
Index ¶
- func InternalServerError(ctx iris.Context, err error, format string, args ...interface{})
- func InternalServerErrorJSON(ctx iris.Context, err error, format string, args ...interface{})
- func LogFailure(logger io.Writer, ctx iris.Context, err HTTPError)
- func RuntimeCallerStack() (s string)
- type HTTPError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InternalServerError ¶
InternalServerError logs to the server's terminal and dispatches to the client the 500 Internal Server Error. Internal Server errors are critical, so we log them to the `os.Stderr`.
func InternalServerErrorJSON ¶
InternalServerErrorJSON acts exactly like `InternalServerError` but instead it sends the data as JSON. Useful for APIs.
func LogFailure ¶
LogFailure will print out the failure to the "logger".
func RuntimeCallerStack ¶
func RuntimeCallerStack() (s string)
RuntimeCallerStack returns the app's `file:line` stacktrace to give more information about an error cause.
Types ¶
type HTTPError ¶
type HTTPError struct { Stack string `json:"-"` // the whole stacktrace. CallerStack string `json:"-"` // the caller, file:lineNumber When time.Time `json:"-"` // the time that the error occurred. // ErrorCode int: maybe a collection of known error codes. StatusCode int `json:"statusCode"` // could be named as "reason" as well // it's the message of the error. Description string `json:"description"` // contains filtered or unexported fields }
HTTPError describes an HTTP error.
func Fail ¶
func Fail(ctx iris.Context, statusCode int, err error, format string, args ...interface{}) HTTPError
Fail will send the status code, write the error's reason and return the HTTPError for further use, i.e logging, see `InternalServerError`.
Click to show internal directories.
Click to hide internal directories.