Categorygithub.com/tiny-go/errors
modulepackage
1.2.1
Repository: https://github.com/tiny-go/errors.git
Documentation: pkg.go.dev

# README

errors

Build Status Report Card GoCover

Collection of HTTP error implementations

HTTP error interface

type Error interface{
  error
  Code() int
}

Implementations

CodeCorresponding error type
400BadRequest
401Unauthorized
403Forbidden
404NotFound
405MethodNotAllowed
406NotAcceptable
408RequestTimeout
409Conflict
500InternalServer
501NotImplemented
503ServiceUnavailable

# Functions

As finds the first error in err's chain that matches target, and if one is found, sets target to that error value and returns true.
BadRequestf returns formatted BadRequest error.
Conflictf returns formatted Conflict error.
Forbiddenf returns formatted Forbidden error.
InternalServerf returns formatted InternalServer error.
Is reports whether any error in err's chain matches target.
MethodNotAllowedf returns formatted MethodNotAllowed error.
New returns an error that formats as the given text.
NewBadRequest is a constructor func for 400 HTTP error.
NewConflict is a constructor func for 409 HTTP error.
NewForbidden is a constructor func for 403 HTTP error.
NewInternalServer is a constructor func for 500 HTTP error.
NewMethodNotAllowed is a constructor func for 405 HTTP error.
NewMethodNotAllowed is a constructor func for 406 HTTP error.
NewNotFound is a constructor func for 404 HTTP error.
NewNotImplemented is a constructor func for 501 HTTP error.
NewRequestTimeout is a constructor func for 408 HTTP error.
NewServiceUnavailable is a constructor func for 503 HTTP error.
NewStatusError is a constructor func for StatusError.
NewUnauthorized is a constructor func for 401 HTTP error.
NotAcceptablef returns formatted NotAcceptable error.
NotFoundf returns formatted NotFound error.
NotImplementedf returns formatted NotImplemented error.
RequestTimeoutf returns formatted RequestTimeout error.
Send provided argument as an HTTP error to the client (retrieving status code if available).
ServiceUnavailablef returns formatted ServiceUnavailable error.
Unauthorizedf returns formatted Unauthorized error.
Unwrap returns the result of calling the Unwrap method on err, if err's type contains an Unwrap method returning error.
WithLogger wrapps provided sender with logger.

# Structs

ResponseLogger provides another (object oriented) approach to log the error.
StatusError is a basic Error interface implementation.

# Interfaces

Error interface describes errors that contain (HTTP or any other) status code.
Logger is a simple error logger.

# Type aliases

BadRequest is a 400 HTTP error.
Conflict is a 409 HTTP error.
Forbidden is a 403 HTTP error.
HandlerFunc is an error handler function, for instance http.Error.
InternalServer is a 500 HTTP error.
MethodNotAllowed is a 404 HTTP error.
Middleware is a chainable sender wrapper func.
NotAcceptable is a 406 HTTP error.
NotFound is a 404 HTTP error.
NotImplemented is a 501 HTTP error.
RequestTimeout is a 404 HTTP error.
Sender is a function that sends an error through the provided response writer.
ServiceUnavailable is a 503 HTTP error.
Unauthorized is a 401 HTTP error.