Documentation ¶
Overview ¶
Copyright (c) 2023 Tiago Melo. All rights reserved. Use of this source code is governed by the MIT License that can be found in the LICENSE file.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsRequestError ¶
IsRequestError checks if an error of type RequestError exists.
func NewRequestError ¶
NewRequestError wraps a provided error with an HTTP status code. This function should be used when handlers encounter expected errors.
Types ¶
type ErrorResponse ¶
type ErrorResponse struct { Error string `json:"error"` Fields map[string]string `json:"fields,omitempty"` }
ErrorResponse is the form used for API responses from failures in the API.
type RequestError ¶
RequestError is used to pass an error during the request through the application with web specific context.
func GetRequestError ¶
func GetRequestError(err error) *RequestError
GetRequestError returns a copy of the RequestError pointer.
func (*RequestError) Error ¶
func (re *RequestError) Error() string
Error implements the error interface. It uses the default message of the wrapped error. This is what will be shown in the services' logs.