errors

package
v1.2.10-rc.3 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2023 License: MIT Imports: 7 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func As

func As(err error, target interface{}) bool

As calls stdlib errors.As.

func DisableLocationTracking

func DisableLocationTracking()

func EnableLocationTracking

func EnableLocationTracking()

func Is

func Is(err, target error) bool

Is calls stdlib errors.Is.

func Unwrap

func Unwrap(err error) error

Unwrap calls stdlib errors.Unwrap.

func Wrap deprecated

func Wrap(code Status, err error) error

Wrap is deprecated.

Deprecated: Use code.Wrap.

Types

type CallSite

type CallSite struct {
	FuncName string `json:"funcName,omitempty" form:"funcName" query:"funcName" validate:"required"`
	File     string `json:"file,omitempty" form:"file" query:"file" validate:"required"`
	Line     int64  `json:"line,omitempty" form:"line" query:"line" validate:"required"`
	// contains filtered or unexported fields
}

func (*CallSite) Copy

func (v *CallSite) Copy() *CallSite

func (*CallSite) CopyAsInterface

func (v *CallSite) CopyAsInterface() interface{}

func (*CallSite) Equal

func (v *CallSite) Equal(u *CallSite) bool

func (*CallSite) IsValid

func (v *CallSite) IsValid() error

func (*CallSite) MarshalBinary

func (v *CallSite) MarshalBinary() ([]byte, error)

func (*CallSite) MarshalJSON added in v1.1.0

func (v *CallSite) MarshalJSON() ([]byte, error)

func (*CallSite) UnmarshalBinary

func (v *CallSite) UnmarshalBinary(data []byte) error

func (*CallSite) UnmarshalBinaryFrom

func (v *CallSite) UnmarshalBinaryFrom(rd io.Reader) error

func (*CallSite) UnmarshalJSON added in v1.1.0

func (v *CallSite) UnmarshalJSON(b []byte) error

type Error

type Error struct {
	Message   string      `json:"message,omitempty" form:"message" query:"message" validate:"required"`
	Code      Status      `json:"code,omitempty" form:"code" query:"code" validate:"required"`
	Cause     *Error      `json:"cause,omitempty" form:"cause" query:"cause" validate:"required"`
	CallStack []*CallSite `json:"callStack,omitempty" form:"callStack" query:"callStack" validate:"required"`
	// contains filtered or unexported fields
}

func Format deprecated

func Format(code Status, format string, args ...interface{}) *Error

Format is deprecated.

Deprecated: Use code.WithFormat.

func FormatWithCause deprecated

func FormatWithCause(code Status, cause error, format string, args ...interface{}) *Error

FormatWithCause is deprecated.

Deprecated: Use code.WithCauseAndFormat.

func New deprecated

func New(code Status, v interface{}) *Error

New is deprecated.

Deprecated: Use code.With.

func (*Error) CodeID

func (e *Error) CodeID() uint64

func (*Error) Copy

func (v *Error) Copy() *Error

func (*Error) CopyAsInterface

func (v *Error) CopyAsInterface() interface{}

func (*Error) Equal

func (v *Error) Equal(u *Error) bool

func (*Error) Error

func (e *Error) Error() string

func (*Error) Format

func (e *Error) Format(f fmt.State, verb rune)

func (*Error) Is

func (e *Error) Is(target error) bool

func (*Error) IsValid

func (v *Error) IsValid() error

func (*Error) MarshalBinary

func (v *Error) MarshalBinary() ([]byte, error)

func (*Error) MarshalJSON

func (v *Error) MarshalJSON() ([]byte, error)

func (*Error) Print

func (e *Error) Print() string

Print prints an error message plus its call stack and causal chain. Compound errors are usually formatted as '<description>: <cause>'. Print will print this out as:

<description>:
<call stack>

<cause>
<call stack>

func (*Error) PrintFullCallstack

func (e *Error) PrintFullCallstack() string

func (*Error) UnmarshalBinary

func (v *Error) UnmarshalBinary(data []byte) error

func (*Error) UnmarshalBinaryFrom

func (v *Error) UnmarshalBinaryFrom(rd io.Reader) error

func (*Error) UnmarshalJSON

func (v *Error) UnmarshalJSON(b []byte) error

func (*Error) Unwrap

func (e *Error) Unwrap() error

type Skip added in v1.1.0

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

func (Skip) With added in v1.1.0

func (s Skip) With(v ...interface{}) *Error

func (Skip) WithCauseAndFormat added in v1.1.0

func (s Skip) WithCauseAndFormat(cause error, format string, args ...interface{}) *Error

func (Skip) WithFormat added in v1.1.0

func (s Skip) WithFormat(format string, args ...interface{}) *Error

func (Skip) Wrap added in v1.1.0

func (s Skip) Wrap(err error) error

type Status

type Status uint64

Status is a request status code.

const BadRequest Status = 400

BadRequest means the request was invalid.

const BadSignerVersion Status = 411

BadSignerVersion means the signer version does not match.

const BadTimestamp Status = 412

BadTimestamp means the timestamp is invalid.

const BadUrlLength Status = 413

BadUrlLength means the url length is too big.

const Conflict Status = 409

Conflict means the request failed due to a conflict.

const Delivered Status = 201

Delivered means the transaction has been delivered.

const EncodingError Status = 502

EncodingError means encoding or decoding failed.

const Expired Status = 407

Expired is returned when a transaction has expired.

const FatalError Status = 503

FatalError means something has gone seriously wrong.

const IncompleteChain Status = 414

IncompleteChain means the chain does not include the full history.

const InsufficientBalance Status = 415

InsufficientBalance means the account balance is insufficient to satisfy the request.

const InsufficientCredits Status = 402

InsufficientCredits means the signer does not have sufficient credits to execute the transaction.

const InternalError Status = 500

InternalError means an internal error occurred.

const InvalidRecord Status = 508

InvalidRecord means the database has one or more invalid records.

const NoPeer Status = 506

NoPeer means the receiver cannot find a peer to satisfy the request.

const NotAllowed Status = 405

NotAllowed means the requested action could not be performed.

const NotFound Status = 404

NotFound means a record could not be found.

const NotReady Status = 504

NotReady means the receiver is not ready to satisfy the request.

const OK Status = 200

OK means the request completed successfully.

const PeerMisbehaved Status = 507

PeerMisbehaved means a peer behaved incorrectly.

const Pending Status = 202

Pending means the transaction is pending.

const Rejected Status = 406

Rejected is returned when a transaction is rejected.

const Remote Status = 203

Remote means the transaction is a local reference to a remote.

const Unauthenticated Status = 401

Unauthenticated means the signature could not be validated.

const Unauthorized Status = 403

Unauthorized means the signer is not authorized to sign the transaction.

const UnknownError Status = 501

UnknownError means an unknown error occurred.

const WrongPartition Status = 301

WrongPartition means the requested resource is assigned to a different network partition.

const WrongType Status = 505

WrongType means the record is not the expected type.

func Code added in v1.1.0

func Code(err error) Status

Code returns the status code if the error is an Error, or 0.

func StatusByName

func StatusByName(name string) (Status, bool)

StatusByName returns the named Status.

func (Status) Delivered added in v1.1.0

func (s Status) Delivered() bool

Delivered returns true if the status represents an executed transaction.

func (Status) Error

func (s Status) Error() string

Error implements error.

func (Status) GetEnumValue

func (v Status) GetEnumValue() uint64

GetEnumValue returns the value of the Status

func (Status) IsClientError added in v1.1.0

func (s Status) IsClientError() bool

IsClientError returns true if the status is a server error.

func (Status) IsKnownError added in v1.1.0

func (s Status) IsKnownError() bool

IsKnownError returns true if the status is non-zero and not UnknownError.

func (Status) IsServerError added in v1.1.0

func (s Status) IsServerError() bool

IsServerError returns true if the status is a server error.

func (Status) MarshalJSON

func (v Status) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Status to JSON as a string.

func (*Status) SetEnumValue

func (v *Status) SetEnumValue(id uint64) bool

SetEnumValue sets the value. SetEnumValue returns false if the value is invalid.

func (Status) Skip added in v1.1.0

func (s Status) Skip(n int) Skip

Skip skips N frames when locating the call site.

func (Status) String

func (v Status) String() string

String returns the name of the Status.

func (Status) Success

func (s Status) Success() bool

Success returns true if the status represents success.

func (*Status) UnmarshalJSON

func (v *Status) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals the Status from JSON as a string.

func (Status) With added in v1.1.0

func (s Status) With(v ...interface{}) *Error

func (Status) WithCauseAndFormat added in v1.1.0

func (s Status) WithCauseAndFormat(cause error, format string, args ...interface{}) *Error

func (Status) WithFormat added in v1.1.0

func (s Status) WithFormat(format string, args ...interface{}) *Error

func (Status) Wrap added in v1.1.0

func (s Status) Wrap(err error) error

Jump to

Keyboard shortcuts

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