gcerrors

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2019 License: Apache-2.0 Imports: 3 Imported by: 292

Documentation

Overview

Package gcerrors provides support for getting error codes from errors returned by Go CDK APIs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorCode

type ErrorCode = gcerr.ErrorCode

An ErrorCode describes the error's category. Programs should act upon an error's code, not its message.

const (
	// Returned by the Code function on a nil error. It is not a valid
	// code for an error.
	OK ErrorCode = gcerr.OK

	// The error could not be categorized.
	Unknown ErrorCode = gcerr.Unknown

	// The resource was not found.
	NotFound ErrorCode = gcerr.NotFound

	// The resource exists, but it should not.
	AlreadyExists ErrorCode = gcerr.AlreadyExists

	// A value given to a Go CDK API is incorrect.
	InvalidArgument ErrorCode = gcerr.InvalidArgument

	// Something unexpected happened. Internal errors always indicate
	// bugs in the Go CDK (or possibly the underlying provider).
	Internal ErrorCode = gcerr.Internal

	// The feature is not implemented.
	Unimplemented ErrorCode = gcerr.Unimplemented

	// The system was in the wrong state.
	FailedPrecondition ErrorCode = gcerr.FailedPrecondition

	// The caller does not have permission to execute the specified operation.
	PermissionDenied ErrorCode = gcerr.PermissionDenied

	// Some resource has been exhausted, typically because a service resource limit
	// has been reached.
	ResourceExhausted ErrorCode = gcerr.ResourceExhausted

	// The operation was canceled.
	Canceled ErrorCode = gcerr.Canceled

	// The operation timed out.
	DeadlineExceeded ErrorCode = gcerr.DeadlineExceeded
)

func Code

func Code(err error) ErrorCode

Code returns the ErrorCode of err if it, or some error it wraps, is an *Error. If err is context.Canceled or context.DeadlineExceeded, or wraps one of those errors, it returns the Canceled or DeadlineExceeded codes, respectively. If err is nil, it returns the special code OK. Otherwise, it returns Unknown.

Jump to

Keyboard shortcuts

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