status

package
v0.50.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: Apache-2.0, BSD-3-Clause Imports: 2 Imported by: 24

Documentation

Overview

Package status implements errors returned by MachineAPIs. MachineAPIs service handlers should return an error created by this package, and machineAPIs clients should expect a corresponding error to be returned from the RPC call.

This package upholds the invariants that a non-nil error may not contain an OK code, and an OK code must result in a nil error.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(c codes.Code, msg string) error

Error returns an error representing c and msg. If c is OK, returns nil.

Types

type Status

type Status struct {
	// contains filtered or unexported fields
}

Status implements error and Status,

func FromError

func FromError(err error) (s *Status, ok bool)

FromError returns a Status representing err if it was produced from this package or has a method `GRPCStatus() *Status`. Otherwise, ok is false and a Status is returned with codes.Unknown and the original error message.

func New

func New(c codes.Code, msg string) *Status

New returns a Status representing c and msg.

func WrapError added in v0.50.0

func WrapError(c codes.Code, msg string, cause error) *Status

WrapError creates an instance of status.Status wrapping the underlying cause along with the code and custom error message.

func (*Status) Cause added in v0.50.0

func (s *Status) Cause() error

Cause returns the underlying error if captured.

func (*Status) Code

func (s *Status) Code() codes.Code

Code returns the status code contained in status.

func (*Status) Error

func (s *Status) Error() string

Error returns the error message for the status. WARNING: There is an unwritten contract for anyone using status.Status. One MUST never change the message text. It expects error code to be in the first square brackets and error message in the next. Therefore, any change made here should never change that. Any square brackets added after code and error are ignored when parsing.

func (*Status) Message

func (s *Status) Message() string

Message returns the message contained in status.

Jump to

Keyboard shortcuts

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