bcerrors

package
v0.0.0-...-6fab949 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package bcerrors provides an error type for Blocky Cloud APIs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Code

func Code(err error) codes.Code

Code returns the codes.Code 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.

func DoNotWrap

func DoNotWrap(err error) bool

DoNotWrap reports whether an error should not be wrapped in the Error type from this package. It returns true if err is a retry error, a context error, io.EOF, or if it wraps one of those.

func ErrorAs

func ErrorAs(err error, target interface{}, errorAs func(error, interface{}) bool) bool

ErrorAs is a helper for the ErrorAs method of an API's portable type. It performs some initial nil checks, and does a single level of unwrapping when err is a *gcerr.Error. Then it calls its errorAs argument, which should be a driver implementation of ErrorAs.

Types

type Error

type Error struct {
	// Code is the error code.
	Code codes.Code
	// contains filtered or unexported fields
}

An Error describes a Go CDK error.

func New

func New(c codes.Code, err error, callDepth int, msg string) *Error

New returns a new error with the given code, underlying error and message. Pass 1 for the call depth if New is called from the function raising the error; pass 2 if it is called from a helper function that was invoked by the original function; and so on.

func Newf

func Newf(c codes.Code, err error, format string, args ...interface{}) *Error

Newf uses format and args to format a message, then calls New.

func (*Error) Error

func (e *Error) Error() string

Error returns the error as a string.

func (*Error) Format

func (e *Error) Format(s fmt.State, c rune)

Format formats the error.

func (*Error) FormatError

func (e *Error) FormatError(p xerrors.Printer) (next error)

FormatError formats the errots.

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the error underlying the receiver, which may be nil.

Jump to

Keyboard shortcuts

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