Documentation
¶
Index ¶
- Variables
- func Check(prefix string, err error)
- func DebugErrorChain(err error) (out string)
- func Find(err error, matcher func(err error) bool) error
- func FindFirstMatching(err error, matcher func(err error) bool) errordeprecated
- func HasAny(err error, cause error) booldeprecated
- func Is(err error, cause error) bool
- func IsClientSideNetworkError(err error) bool
- func IsShuttingDown() bool
- func Retry(retries uint64, f func(ctx context.Context) error) error
- func RetryContext(ctx context.Context, retries uint64, f func(ctx context.Context) error) error
- func SetupSignalHandler(gracefulShutdownDelay time.Duration) <-chan os.Signal
- func Status(code codes.Code, message string) error
- func Statusf(code codes.Code, format string, args ...interface{}) error
- func Walk(err error, processor func(err error) (bool, error)) error
- func Wrap(err error, message string) error
- func WrapCode(code codes.Code, err error, message string) error
- func Wrapf(err error, format string, args ...interface{}) error
- func WrapfCode(code codes.Code, err error, format string, args ...interface{}) error
- func WriteError(ctx context.Context, w http.ResponseWriter, message string, err error)deprecated
- type ErrorCodedeprecated
- func C(code string) ErrorCodedeprecated
- type ErrorResponsedeprecated
- func HTTPErrorFromStatus(status int, ctx context.Context, cause error, code ErrorCode, ...) *ErrorResponsedeprecated
- func InvalidJSONError(ctx context.Context, err error) *ErrorResponsedeprecated
- func MissingBodyError(ctx context.Context) *ErrorResponsedeprecated
- func RequestValidationError(ctx context.Context, errors url.Values) *ErrorResponsedeprecated
- func ServiceUnavailableError(ctx context.Context, cause error, serviceName string) *ErrorResponsedeprecated
- func ToErrorResponse(ctx context.Context, err error) *ErrorResponsedeprecated
- func UnexpectedError(ctx context.Context, cause error) *ErrorResponsedeprecated
- type FatalError
- type RetryableError
Constants ¶
This section is empty.
Variables ¶
var ( // Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPBadRequestError = newErrorClass(http.StatusBadRequest) // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPUnauthorizedError = newErrorClass(http.StatusUnauthorized) // Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPPaymentRequiredError = newErrorClass(http.StatusPaymentRequired) // Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPForbiddenError = newErrorClass(http.StatusForbidden) // Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPNotFoundError = newErrorClass(http.StatusNotFound) // Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPMethodNotAllowedError = newErrorClass(http.StatusMethodNotAllowed) // Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPNotAcceptableError = newErrorClass(http.StatusNotAcceptable) // Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPProxyAuthRequiredError = newErrorClass(http.StatusProxyAuthRequired) // Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPRequestTimeoutError = newErrorClass(http.StatusRequestTimeout) // Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPConflictError = newErrorClass(http.StatusConflict) // Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPGoneError = newErrorClass(http.StatusGone) // Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPLengthRequiredError = newErrorClass(http.StatusLengthRequired) // Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPPreconditionFailedError = newErrorClass(http.StatusPreconditionFailed) // Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPRequestEntityTooLargeError = newErrorClass(http.StatusRequestEntityTooLarge) // Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPRequestURITooLongError = newErrorClass(http.StatusRequestURITooLong) // Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPUnsupportedMediaTypeError = newErrorClass(http.StatusUnsupportedMediaType) // Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPRequestedRangeNotSatisfiableError = newErrorClass(http.StatusRequestedRangeNotSatisfiable) // Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPExpectationFailedError = newErrorClass(http.StatusExpectationFailed) // Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPTeapotError = newErrorClass(http.StatusTeapot) // Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPUnprocessableEntityError = newErrorClass(http.StatusUnprocessableEntity) // Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPLockedError = newErrorClass(http.StatusLocked) // Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPFailedDependencyError = newErrorClass(http.StatusFailedDependency) // Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPUpgradeRequiredError = newErrorClass(http.StatusUpgradeRequired) // Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPPreconditionRequiredError = newErrorClass(http.StatusPreconditionRequired) // Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPTooManyRequestsError = newErrorClass(http.StatusTooManyRequests) // Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPRequestHeaderFieldsTooLargeError = newErrorClass(http.StatusRequestHeaderFieldsTooLarge) // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPUnavailableForLegalReasonsError = newErrorClass(http.StatusUnavailableForLegalReasons) )
var ( // Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPInternalServerError = newErrorClass(http.StatusInternalServerError) // Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPNotImplementedError = newErrorClass(http.StatusNotImplemented) // Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPBadGatewayError = newErrorClass(http.StatusBadGateway) // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPServiceUnavailableError = newErrorClass(http.StatusServiceUnavailable) // Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPGatewayTimeoutError = newErrorClass(http.StatusGatewayTimeout) // Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPHTTPVersionNotSupportedError = newErrorClass(http.StatusHTTPVersionNotSupported) // Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPVariantAlsoNegotiatesError = newErrorClass(http.StatusVariantAlsoNegotiates) // Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPInsufficientStorageError = newErrorClass(http.StatusInsufficientStorage) // Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPLoopDetectedError = newErrorClass(http.StatusLoopDetected) // Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPNotExtendedError = newErrorClass(http.StatusNotExtended) // Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, // which provides a more comprehensive and flexible approach to error handling in HTTP contexts. HTTPNetworkAuthenticationRequiredError = newErrorClass(http.StatusNetworkAuthenticationRequired) )
var ErrorCheck = Check
Deprecated: use `Check` with `derr.Check`).
Functions ¶
func DebugErrorChain ¶
DebugErrorChain returns a debug human friendly string represents the full stack of errors with the type of.
func Find ¶
Find walks the error(s) stack (causes chain) and return the first error matching the `matcher` function received in argument.
Act exactly like `errors.Is` but using a matcher function instead of trying to match a particular address.
func FindFirstMatching
deprecated
func Is ¶
Is reports whether any error in err's chain matches target.
The chain consists of err itself followed by the sequence of errors obtained by repeatedly calling Unwrap (or Cause).
func IsClientSideNetworkError ¶
IsClientSideNetworkError returns whether the error received is a network error caused by the client side that could not be possibly handled correctly on the server side anyway.
func IsShuttingDown ¶
func IsShuttingDown() bool
func Retry ¶
Retry re-executes the function `f` if it returns an error. If you return a `derr.FatalError` your function will not be retried.
func RetryContext ¶
RetryContext re-executes the function `f` if it returns an error. If you return a `derr.FatalError` your function will not be retried.
func SetupSignalHandler ¶
this is a graceful delay to allow residual traffic sent by the load balancer to be processed without returning 500. Once the delay has passed then the service can be shutdown
func Walk ¶
Walk traverse error causes in a top to bottom fashion. Starting from the top `err` received, will invoke `processor(err)` with it. Walk calls immediately on start the `processor(err)` with the root error received that can be `nil`, so you must ready to handle the fact that you might receive `nil`.
If the `processor` returns `true`, check if `err` has a cause and continue walking it like this recursively. If `processor` return a `non-nil` value, stop walking at this point. If `processor` returns an `error` stop walking from there and bubble up the error through `Walk` return value.
Returns an `error` if `processor` returned an `error`, `nil` otherwise
func Wrapf ¶
Wrapf is a shortcut for `pkgErrors.Wrapf` (where `pkgErrors` is `github.com/pkg/errors`)
func WriteError
deprecated
WriteError writes the receiver error to HTTP and log it into a Zap logger at the same time with the right level based on the actual status code. The `WriteError` handles various type for the `err` parameter.
Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, which provides a more comprehensive and flexible approach to error handling in HTTP contexts.
Types ¶
type ErrorCode
deprecated
type ErrorCode string
Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, which provides a more comprehensive and flexible approach to error handling in HTTP contexts.
func C
deprecated
C is a sugar syntax for `derr.ErrorCode("a_string_code")` (sugared to `derr.C("a_string_code")`)
Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, which provides a more comprehensive and flexible approach to error handling in HTTP contexts.
type ErrorResponse
deprecated
type ErrorResponse struct {
Code ErrorCode `json:"code"`
TraceID string `json:"trace_id"`
Status int `json:"-"`
Message string `json:"message"`
Details map[string]interface{} `json:"details,omitempty"`
Causer error `json:"-"`
}
Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, which provides a more comprehensive and flexible approach to error handling in HTTP contexts.
func HTTPErrorFromStatus
deprecated
func HTTPErrorFromStatus(status int, ctx context.Context, cause error, code ErrorCode, message interface{}, keyvals ...interface{}) *ErrorResponse
HTTPErrorFromStatus can be used to programmaticaly route the right status to one of the HTTP error class above
Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, which provides a more comprehensive and flexible approach to error handling in HTTP contexts.
func InvalidJSONError
deprecated
func InvalidJSONError(ctx context.Context, err error) *ErrorResponse
Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, which provides a more comprehensive and flexible approach to error handling in HTTP contexts.
func MissingBodyError
deprecated
func MissingBodyError(ctx context.Context) *ErrorResponse
Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, which provides a more comprehensive and flexible approach to error handling in HTTP contexts.
func RequestValidationError
deprecated
func RequestValidationError(ctx context.Context, errors url.Values) *ErrorResponse
Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, which provides a more comprehensive and flexible approach to error handling in HTTP contexts.
func ServiceUnavailableError
deprecated
func ServiceUnavailableError(ctx context.Context, cause error, serviceName string) *ErrorResponse
ServiceUnavailableError represents a failure at the transport layer to reach a given micro-service. Note that while `serviceName` is required, it's not directly available to final response for now, will probably encrypt it into an opaque string if you ever make usage of it
Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, which provides a more comprehensive and flexible approach to error handling in HTTP contexts.
func ToErrorResponse
deprecated
func ToErrorResponse(ctx context.Context, err error) *ErrorResponse
ToErrorResponse turns a plain `error` interface into a proper `ErrorResponse` object. It does so with the following rules:
- If `err` is already an `ErrorResponse`, turns it into such and returns it. - If `err` was wrapped, find the most cause which is an `ErrorResponse` and returns it. - If `err` is a status.Status (or one that was wrapped), convert it to an ErrorResponse - Otherwise, return an `UnexpectedError` with the cause sets to `err` received.
Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, which provides a more comprehensive and flexible approach to error handling in HTTP contexts.
func UnexpectedError
deprecated
func UnexpectedError(ctx context.Context, cause error) *ErrorResponse
Deprecated: HTTP error handling has moved to [dhttp](https://github.com/streamingfast/dhttp) package, which provides a more comprehensive and flexible approach to error handling in HTTP contexts.
func (*ErrorResponse) Cause ¶
func (e *ErrorResponse) Cause() error
func (*ErrorResponse) Error ¶
func (e *ErrorResponse) Error() string
func (*ErrorResponse) ResponseStatus ¶
func (e *ErrorResponse) ResponseStatus() int
type FatalError ¶
type FatalError struct {
// contains filtered or unexported fields
}
func NewFatalError ¶
func NewFatalError(original error) *FatalError
NewFatalError creates a new FatalError struct ensuring `original` error is non-nil otherwise this function panics with an error.
func (*FatalError) Error ¶
func (r *FatalError) Error() string
func (*FatalError) Unwrap ¶
func (r *FatalError) Unwrap() error
type RetryableError ¶
type RetryableError struct {
// contains filtered or unexported fields
}
RetryableError can be returned by your handler either [SinkerHandlers#HandleBlockScopedData] or [SinkerHandlers#HandleBlockUndoSignal] to notify the sinker that it's a retryable error and the stream can continue
func NewRetryableError ¶
func NewRetryableError(original error) *RetryableError
NewRetryableError creates a new RetryableError struct ensuring `original` error is non-nil otherwise this function panics with an error.
func (*RetryableError) Error ¶
func (r *RetryableError) Error() string
func (*RetryableError) Unwrap ¶
func (r *RetryableError) Unwrap() error