go: firebase.google.com/go/errorutils Index | Files

package errorutils

import "firebase.google.com/go/errorutils"

Package errorutils provides functions for checking and handling error conditions.

Index

Package Files

errorutils.go

func HTTPResponse Uses

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 Uses

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 Uses

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 Uses

func IsCancelled(err error) bool

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

func IsConflict Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

func IsInvalidArgument(err error) bool

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

func IsNotFound Uses

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 Uses

func IsOutOfRange(err error) bool

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

func IsPermissionDenied Uses

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 Uses

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 Uses

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 Uses

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 Uses

func IsUnknown(err error) bool

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

This typically indicates a server bug.

Package errorutils imports 2 packages (graph). Updated 2020-06-23. Refresh now. Tools for package owners.