errorutils

package
v4.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 2 Imported by: 7

Documentation

Overview

Package errorutils provides functions for checking and handling error conditions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTPResponse

func HTTPResponse(err error) *http.Response

HTTPResponse returns the http.Response instance that caused the given error.

If the error was not caused by an HTTP error response, returns nil.

Returns a buffered copy of the original response received from the network stack. It is safe to read the response content from the returned http.Response.

func IsAborted

func IsAborted(err error) bool

IsAborted checks if the given error was due to a concurrency conflict, such as a read-modify-write conflict.

func IsAlreadyExists

func IsAlreadyExists(err error) bool

IsAlreadyExists checks if the given error was because a resource that a client tried to create already exists.

func IsCancelled

func IsCancelled(err error) bool

IsCancelled checks if the given error was due to the client cancelling a request.

func IsConflict

func IsConflict(err error) bool

IsConflict checks if the given error was due to a concurrency conflict, such as a read-modify-write conflict.

This represents an HTTP 409 Conflict status code, without additional information to distinguish between ABORTED or ALREADY_EXISTS error conditions.

func IsDataLoss

func IsDataLoss(err error) bool

IsDataLoss checks if the given error was due to an unrecoverable data loss or corruption.

The client should report such errors to the end user.

func IsDeadlineExceeded

func IsDeadlineExceeded(err error) bool

IsDeadlineExceeded checks if the given error was due a request exceeding a deadline.

This will happen only if the caller sets a deadline that is shorter than the method's default deadline (i.e. requested deadline is not enough for the server to process the request) and the request did not finish within the deadline.

func IsFailedPrecondition

func IsFailedPrecondition(err error) bool

IsFailedPrecondition checks if the given error was because a request could not be executed in the current system state, such as deleting a non-empty directory.

func IsInternal

func IsInternal(err error) bool

IsInternal checks if the given error was due to an internal server error.

This typically indicates a server bug.

func IsInvalidArgument

func IsInvalidArgument(err error) bool

IsInvalidArgument checks if the given error was due to an invalid client argument.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound checks if the given error was due to a specified resource being not found.

This may also occur when the request is rejected by undisclosed reasons, such as whitelisting.

func IsOutOfRange

func IsOutOfRange(err error) bool

IsOutOfRange checks if the given error due to an invalid range specified by the client.

func IsPermissionDenied

func IsPermissionDenied(err error) bool

IsPermissionDenied checks if the given error was due to a client not having suffificient permissions.

This can happen because the OAuth token does not have the right scopes, the client doesn't have permission, or the API has not been enabled for the client project.

func IsResourceExhausted

func IsResourceExhausted(err error) bool

IsResourceExhausted checks if the given error was caused by either running out of a quota or reaching a rate limit.

func IsUnauthenticated

func IsUnauthenticated(err error) bool

IsUnauthenticated checks if the given error was caused by an unauthenticated request.

Unauthenticated requests are due to missing, invalid, or expired OAuth token.

func IsUnavailable

func IsUnavailable(err error) bool

IsUnavailable checks if the given error was caused by an unavailable service.

This typically indicates that the target service is temporarily down.

func IsUnknown

func IsUnknown(err error) bool

IsUnknown checks if the given error was cuased by an unknown server error.

This typically indicates a server bug.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL