Documentation ¶
Index ¶
- Constants
- type Error
- func New(status int, code string, msgFormat string, vals ...interface{}) *Error
- func WithAccountNotFound(msgFormat string, vals ...interface{}) *Error
- func WithBadNonce(msgFormat string, vals ...interface{}) *Error
- func WithConflict(msgFormat string, vals ...interface{}) *Error
- func WithContentLengthRequired() *Error
- func WithFailedToReadRequestBody(msgFormat string, vals ...interface{}) *Error
- func WithForbidden(msgFormat string, vals ...interface{}) *Error
- func WithInvalidContentType(msgFormat string, vals ...interface{}) *Error
- func WithInvalidJSON(msgFormat string, vals ...interface{}) *Error
- func WithInvalidParam(msgFormat string, vals ...interface{}) *Error
- func WithInvalidRequest(msgFormat string, vals ...interface{}) *Error
- func WithMalformed(msgFormat string, vals ...interface{}) *Error
- func WithNotFound(msgFormat string, vals ...interface{}) *Error
- func WithNotReady(msgFormat string, vals ...interface{}) *Error
- func WithRateLimitExceeded(msgFormat string, vals ...interface{}) *Error
- func WithRequestTooLarge(msgFormat string, vals ...interface{}) *Error
- func WithUnauthorized(msgFormat string, vals ...interface{}) *Error
- func WithUnexpected(msgFormat string, vals ...interface{}) *Error
- type ManyError
Constants ¶
const ( // AccountNotFound when requested account not found AccountNotFound = "account_not_found" // BadNonce is returned for bad nonce. BadNonce = "bad_nonce" // Conflict is returned whith 409 CONFLICT response code. Conflict = "conflict" // Connection is returned when connection failed. Connection = "connection" // ContentLengthRequired is returned when request does not specify ContentLength. ContentLengthRequired = "content_length_required" // FailedToReadRequestBody is returned when there's an error reading the HTTP body of the request. FailedToReadRequestBody = "request_body" // Forbidden is returned when the client is not authorized to access the resource indicated. Forbidden = "forbidden" // InvalidContentType is returned when request specifies invalid Content-Type. InvalidContentType = "invalid_content_type" // InvalidJSON is returned when we were unable to parse a client supplied JSON Payload. InvalidJSON = "invalid_json" // InvalidParam is returned where a URL parameter, or other type of generalized parameters value is invalid. InvalidParam = "invalid_parameter" // InvalidRequest is returned when the request validation failed. InvalidRequest = "invalid_request" // Malformed is returned when the request was malformed. Malformed = "malformed" // NotFound is returned when the requested URL doesn't exist. NotFound = "not_found" // NotReady is returned when the service is not ready to serve NotReady = "not_ready" // RateLimitExceeded is returned when the client has exceeded their request allotment. RateLimitExceeded = "rate_limit_exceeded" // RequestFailed is returned when an outbound request failed. RequestFailed = "request_failed" // RequestTooLarge is returned when the client provided payload is larger than allowed for the particular resource. RequestTooLarge = "request_too_large" Unauthorized = "unauthorized" // Unexpected is returned when something went wrong. Unexpected = "unexpected" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Error ¶
type Error struct { // HTTPStatus contains the HTTP status code that should be used for this error HTTPStatus int `json:"-"` // Code identifies the particular error condition [for programatic consumers] Code string `json:"code"` // Message is an textual description of the error Message string `json:"message"` // Cause is the original error Cause error `json:"-"` }
Error represents a single error from API.
func WithAccountNotFound ¶
WithAccountNotFound for builds a new Error instance with AccountNotFound code
func WithBadNonce ¶
WithBadNonce for builds a new Error instance with BadNonce code
func WithConflict ¶
WithConflict for builds a new Error instance with Conflict code
func WithContentLengthRequired ¶
func WithContentLengthRequired() *Error
WithContentLengthRequired for builds a new Error instance with ContentLengthRequired code
func WithFailedToReadRequestBody ¶
WithFailedToReadRequestBody for builds a new Error instance with FailedToReadRequestBody code
func WithForbidden ¶
WithForbidden for builds a new Error instance with Forbidden code
func WithInvalidContentType ¶
WithInvalidContentType for builds a new Error instance with InvalidContentType code
func WithInvalidJSON ¶
WithInvalidJSON for builds a new Error instance with InvalidJSON code
func WithInvalidParam ¶
WithInvalidParam for builds a new Error instance with InvalidParam code
func WithInvalidRequest ¶
WithInvalidRequest for builds a new Error instance with InvalidRequest code
func WithMalformed ¶
WithMalformed for builds a new Error instance with Malformed code
func WithNotFound ¶
WithNotFound for builds a new Error instance with NotFound code
func WithNotReady ¶
WithNotReady for builds a new Error instance with NotReady code
func WithRateLimitExceeded ¶
WithRateLimitExceeded for builds a new Error instance with RateLimitExceeded code
func WithRequestTooLarge ¶
WithRequestTooLarge for builds a new Error instance with RequestTooLarge code
func WithUnauthorized ¶
WithUnauthorized for builds a new Error instance with Unauthorized code
func WithUnexpected ¶
WithUnexpected for builds a new Error instance with Unexpected code
func (*Error) WriteHTTPResponse ¶
func (e *Error) WriteHTTPResponse(w http.ResponseWriter, r *http.Request)
WriteHTTPResponse implements how to serialize this error into a HTTP Response
type ManyError ¶
type ManyError struct { // HTTPStatus contains the HTTP status code that should be used for this error HTTPStatus int `json:"-"` // Code identifies the particular error condition [for programatic consumers] Code string `json:"code,omitempty"` // Message is an textual description of the error Message string `json:"message,omitempty"` Errors map[string]*Error `json:"errors,omitempty"` }
ManyError identifies many errors from API.
func (*ManyError) WriteHTTPResponse ¶
func (m *ManyError) WriteHTTPResponse(w http.ResponseWriter, r *http.Request)
WriteHTTPResponse implements how to serialize this error into a HTTP Response