errors

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 25, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeUrlDebugInfo           = typeUrlPrefix + "DebugInfo"
	TypeUrlResourceInfo        = typeUrlPrefix + "ResourceInfo"
	TypeUrlBadRequest          = typeUrlPrefix + "BadRequest"
	TypeUrlPreconditionFailure = typeUrlPrefix + "PreconditionFailure"
	TypeUrlErrorInfo           = typeUrlPrefix + "ErrorInfo"
	TypeUrlQuotaFailure        = typeUrlPrefix + "QuotaFailure"
	TypeUrlRequestInfo         = typeUrlPrefix + "RequestInfo"
	TypeUrlHelp                = typeUrlPrefix + "Help"
	TypeUrlLocalizedMessage    = typeUrlPrefix + "LocalizedMessage"
)

Variables

This section is empty.

Functions

func Annotate

func Annotate(cause error, annotations ...Annotation) error

func Decode

func Decode(body io.Reader) (err error)

func Encode

func Encode(err error) (data []byte, _err error)

func Flatten

func Flatten(err error) error

func NewAborted

func NewAborted(message string, info ErrorInfo) (err error)

func NewAlreadyExists

func NewAlreadyExists(message string, info ResourceInfo) (err error)

func NewBadRequest

func NewBadRequest(message string, violations ...FieldViolation) error

func NewCancelled

func NewCancelled(message string) (err error)

func NewDataLoss

func NewDataLoss(message string, info DebugInfo) (err error)

func NewDeadlineExceeded

func NewDeadlineExceeded(message string, info DebugInfo) (err error)

func NewFailedPrecondition

func NewFailedPrecondition(message string, violations ...TypedViolation) error

func NewInternal

func NewInternal(message string, info DebugInfo) (err error)

func NewNotFound

func NewNotFound(message string, detail ResourceInfo) error

func NewOutOfRange

func NewOutOfRange(message string, violations ...FieldViolation) (err error)

func NewPermissionDenied

func NewPermissionDenied(message string, info ErrorInfo) (err error)

func NewResourceExhausted

func NewResourceExhausted(message string, violations ...Violation) (err error)

func NewUnauthenticated

func NewUnauthenticated(message string, info ErrorInfo) (err error)

func NewUnavailable

func NewUnavailable(message string, info DebugInfo) (err error)

func NewUnimplemented

func NewUnimplemented(message string) (err error)

func NewUnknown

func NewUnknown(message string, info DebugInfo) (err error)

func RegisterType

func RegisterType(typeUrl string, provider func() Any)

Types

type Annotation

type Annotation func(err *annotated)

func WithCode

func WithCode(code StatusCode) Annotation

func WithDetail

func WithDetail(details ...Any) Annotation

func WithHelp

func WithHelp(links ...Link) Annotation

func WithHttpCode added in v0.1.1

func WithHttpCode(httpCode int) Annotation

func WithLocalizedMessage

func WithLocalizedMessage(local string, message string) Annotation

func WithMessage

func WithMessage(message string) Annotation

func WithRequestInfo

func WithRequestInfo(requestId, servingData string) Annotation

func WithStack

func WithStack() Annotation

type Any

type Any interface {
	TypeUrl() string
}

func Details

func Details(err error) []Any

type AnyDetail

type AnyDetail map[string]interface{}

func (AnyDetail) MarshalJSON

func (d AnyDetail) MarshalJSON() ([]byte, error)

func (AnyDetail) TypeUrl

func (d AnyDetail) TypeUrl() string

type BadRequest

type BadRequest struct {
	FieldViolations []FieldViolation `json:"fieldViolations,omitempty"`
}

func (BadRequest) Format

func (d BadRequest) Format(f fmt.State, verb rune)

func (BadRequest) MarshalJSON

func (d BadRequest) MarshalJSON() ([]byte, error)

func (BadRequest) TypeUrl

func (d BadRequest) TypeUrl() string

type DebugInfo

type DebugInfo struct {
	StackEntries []string `json:"stackEntries,omitempty"`
	Detail       string   `json:"detail,omitempty"`
}

func (DebugInfo) Format

func (d DebugInfo) Format(f fmt.State, verb rune)

func (DebugInfo) MarshalJSON

func (d DebugInfo) MarshalJSON() ([]byte, error)

func (DebugInfo) TypeUrl

func (d DebugInfo) TypeUrl() string

type ErrorInfo

type ErrorInfo struct {
	Reason   string            `json:"reason,omitempty"`
	Domain   string            `json:"domain,omitempty"`
	Metadata map[string]string `json:"metadata,omitempty"`
}

func (ErrorInfo) Format

func (d ErrorInfo) Format(f fmt.State, verb rune)

func (ErrorInfo) MarshalJSON

func (d ErrorInfo) MarshalJSON() ([]byte, error)

func (ErrorInfo) TypeUrl

func (d ErrorInfo) TypeUrl() string

type FieldViolation

type FieldViolation struct {
	Field       string `json:"field,omitempty"`
	Description string `json:"description,omitempty"`
}

type Help

type Help struct {
	Links []Link `json:"links,omitempty"`
}

func (Help) Format

func (d Help) Format(f fmt.State, verb rune)

func (Help) MarshalJSON

func (d Help) MarshalJSON() ([]byte, error)

func (Help) TypeUrl

func (d Help) TypeUrl() string
type Link struct {
	Description string `json:"description,omitempty"`
	Url         string `json:"url,omitempty"`
}

type LocalizedMessage

type LocalizedMessage struct {
	Local   string `json:"local,omitempty"`
	Message string `json:"message,omitempty"`
}

func (LocalizedMessage) Format

func (d LocalizedMessage) Format(f fmt.State, verb rune)

func (LocalizedMessage) MarshalJSON

func (d LocalizedMessage) MarshalJSON() ([]byte, error)

func (LocalizedMessage) TypeUrl

func (d LocalizedMessage) TypeUrl() string

type PreconditionFailure

type PreconditionFailure struct {
	Violations []TypedViolation `json:"violations,omitempty"`
}

func (PreconditionFailure) Format

func (d PreconditionFailure) Format(f fmt.State, verb rune)

func (PreconditionFailure) MarshalJSON

func (d PreconditionFailure) MarshalJSON() ([]byte, error)

func (PreconditionFailure) TypeUrl

func (d PreconditionFailure) TypeUrl() string

type QuotaFailure

type QuotaFailure struct {
	Violations []Violation `json:"violations,omitempty"`
}

func (QuotaFailure) Format

func (d QuotaFailure) Format(f fmt.State, verb rune)

func (QuotaFailure) MarshalJSON

func (d QuotaFailure) MarshalJSON() ([]byte, error)

func (QuotaFailure) TypeUrl

func (d QuotaFailure) TypeUrl() string

type RequestInfo

type RequestInfo struct {
	RequestId   string `json:"requestId,omitempty"`
	ServingData string `json:"servingData,omitempty"`
}

func (RequestInfo) Format

func (d RequestInfo) Format(f fmt.State, verb rune)

func (RequestInfo) MarshalJSON

func (d RequestInfo) MarshalJSON() ([]byte, error)

func (RequestInfo) TypeUrl

func (d RequestInfo) TypeUrl() string

type ResourceInfo

type ResourceInfo struct {
	ResourceType string `json:"resourceType,omitempty"`
	ResourceName string `json:"resourceName,omitempty"`
	Owner        string `json:"owner,omitempty"`
	Description  string `json:"description,omitempty"`
}

func (ResourceInfo) Format

func (d ResourceInfo) Format(f fmt.State, verb rune)

func (ResourceInfo) MarshalJSON

func (d ResourceInfo) MarshalJSON() ([]byte, error)

func (ResourceInfo) TypeUrl

func (d ResourceInfo) TypeUrl() string

type RoundTripper added in v0.1.1

type RoundTripper struct {
	Parent http.RoundTripper
}

func (*RoundTripper) RoundTrip added in v0.1.1

func (e *RoundTripper) RoundTrip(req *http.Request) (resp *http.Response, err error)

type StatusCode

type StatusCode int
const (
	OK StatusCode = iota
	Cancelled
	Unknown
	InvalidArgument
	DeadlineExceeded
	NotFound
	AlreadyExists
	PermissionDenied
	ResourceExhausted
	FailedPrecondition
	Aborted
	OutOfRange
	Unimplemented
	Internal
	Unavailable
	DataLoss
	Unauthenticated
)

func Code

func Code(err error) StatusCode

func HttpToCode added in v0.1.1

func HttpToCode(httpCode int) StatusCode

func StrToCode

func StrToCode(status string) StatusCode

func (StatusCode) Error

func (c StatusCode) Error() string

func (StatusCode) HttpCode

func (c StatusCode) HttpCode() int

func (StatusCode) String

func (c StatusCode) String() string

func (StatusCode) Valid

func (c StatusCode) Valid() bool

type TypedViolation

type TypedViolation struct {
	Type        string `json:"type,omitempty"`
	Subject     string `json:"subject,omitempty"`
	Description string `json:"description,omitempty"`
}

type Violation

type Violation struct {
	Subject     string `json:"subject,omitempty"`
	Description string `json:"description,omitempty"`
}

Jump to

Keyboard shortcuts

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