Documentation ¶
Overview ¶
Package errorutils provides functions for checking and handling error conditions.
Index ¶
- func HTTPResponse(err error) *http.Response
- func IsAborted(err error) bool
- func IsAlreadyExists(err error) bool
- func IsCancelled(err error) bool
- func IsConflict(err error) bool
- func IsDataLoss(err error) bool
- func IsDeadlineExceeded(err error) bool
- func IsFailedPrecondition(err error) bool
- func IsInternal(err error) bool
- func IsInvalidArgument(err error) bool
- func IsNotFound(err error) bool
- func IsOutOfRange(err error) bool
- func IsPermissionDenied(err error) bool
- func IsResourceExhausted(err error) bool
- func IsUnauthenticated(err error) bool
- func IsUnavailable(err error) bool
- func IsUnknown(err error) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HTTPResponse ¶
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 ¶
IsAborted checks if the given error was due to a concurrency conflict, such as a read-modify-write conflict.
func IsAlreadyExists ¶
IsAlreadyExists checks if the given error was because a resource that a client tried to create already exists.
func IsCancelled ¶
IsCancelled checks if the given error was due to the client cancelling a request.
func IsConflict ¶
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 ¶
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 ¶
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 ¶
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 ¶
IsInternal checks if the given error was due to an internal server error.
This typically indicates a server bug.
func IsInvalidArgument ¶
IsInvalidArgument checks if the given error was due to an invalid client argument.
func IsNotFound ¶
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 ¶
IsOutOfRange checks if the given error due to an invalid range specified by the client.
func IsPermissionDenied ¶
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 ¶
IsResourceExhausted checks if the given error was caused by either running out of a quota or reaching a rate limit.
func IsUnauthenticated ¶
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 ¶
IsUnavailable checks if the given error was caused by an unavailable service.
This typically indicates that the target service is temporarily down.
Types ¶
This section is empty.