errors

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: May 23, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package errors provides canonical error codes for cloudemu services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAlreadyExists

func IsAlreadyExists(err error) bool

IsAlreadyExists returns true if the error is an AlreadyExists error.

func IsFailedPrecondition

func IsFailedPrecondition(err error) bool

IsFailedPrecondition returns true if the error is a FailedPrecondition error.

func IsInvalidArgument

func IsInvalidArgument(err error) bool

IsInvalidArgument returns true if the error is an InvalidArgument error.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns true if the error is a NotFound error.

func IsPermissionDenied

func IsPermissionDenied(err error) bool

IsPermissionDenied returns true if the error is a PermissionDenied error.

func IsThrottled

func IsThrottled(err error) bool

IsThrottled returns true if the error is a Throttled error.

Types

type Code

type Code int

Code represents a canonical error code.

const (
	OK Code = iota
	NotFound
	AlreadyExists
	InvalidArgument
	FailedPrecondition
	PermissionDenied
	Throttled
	Internal
	Unimplemented
	ResourceExhausted
	Unavailable
)

func GetCode

func GetCode(err error) Code

GetCode extracts the error code from an error. Returns Internal for non-cloudemu errors and OK for nil errors.

func (Code) String

func (c Code) String() string

String returns the string representation of the error code.

type Error

type Error struct {
	Code    Code
	Message string
}

Error is a cloudemu error with a code and message.

func New

func New(code Code, msg string) *Error

New creates a new Error with the given code and message.

func Newf

func Newf(code Code, format string, args ...any) *Error

Newf creates a new Error with the given code and formatted message.

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface.

Jump to

Keyboard shortcuts

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