zerrors

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: MIT Imports: 5 Imported by: 1

README

Zerrors

A error primitives package with a list of grpc based errors that can be used to describe root causes.

Originally forked and extracted from Zitadel zerrors package: Zitadel Errors

Install

go get github.com/mscno/zerrors

This will install the base zerrors package and as well as the httperrors adapter.

If you want to use the grpc adapter, you will need to install the zerrors-grpc package:

go get github.com/mscno/zerrors/grpczerrors

Usage

Basic Usage
package main

import (
    "fmt"
    "github.com/mscno/zerrors"
)

func main() {
	rooterr := fmt.Errorf("root error")
    err := zerrors.ThrowNotFound(rooterr,"NOT_FOUND","my error")
    fmt.Println(err)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(err error, needle string) bool

Contains compares the error message with needle

func IsDeadlineExceeded

func IsDeadlineExceeded(err error) bool

func IsErrorAlreadyExists

func IsErrorAlreadyExists(err error) bool

func IsErrorInvalidArgument

func IsErrorInvalidArgument(err error) bool

func IsInternal

func IsInternal(err error) bool

func IsNotFound

func IsNotFound(err error) bool

func IsPermissionDenied

func IsPermissionDenied(err error) bool

func IsPreconditionFailed

func IsPreconditionFailed(err error) bool

func IsResourceExhausted

func IsResourceExhausted(err error) bool

func IsUnauthenticated

func IsUnauthenticated(err error) bool

func IsUnavailable

func IsUnavailable(err error) bool

func IsUnimplemented

func IsUnimplemented(err error) bool

func IsUnknown

func IsUnknown(err error) bool

func ThrowAlreadyExists

func ThrowAlreadyExists(parent error, id, message string) error

func ThrowAlreadyExistsf

func ThrowAlreadyExistsf(parent error, id, format string, a ...interface{}) error

func ThrowDeadlineExceeded

func ThrowDeadlineExceeded(parent error, id, message string) error

func ThrowDeadlineExceededf

func ThrowDeadlineExceededf(parent error, id, format string, a ...interface{}) error

func ThrowError

func ThrowError(parent error, id, message string) error

func ThrowInternal

func ThrowInternal(parent error, id, message string, kv ...any) error

func ThrowInvalidArgument

func ThrowInvalidArgument(parent error, id, message string) error

func ThrowInvalidArgumentf

func ThrowInvalidArgumentf(parent error, id, format string, a ...interface{}) error

func ThrowNotFound

func ThrowNotFound(parent error, id, message string) error

func ThrowNotFoundResource

func ThrowNotFoundResource(action, kind, name string) error

func ThrowNotFoundResourceParent

func ThrowNotFoundResourceParent(action, kind, parent, parentKind string) error

func ThrowNotFoundf

func ThrowNotFoundf(parent error, id, format string, a ...interface{}) error

func ThrowPermissionDenied

func ThrowPermissionDenied(parent error, id, message string) error

func ThrowPermissionDeniedf

func ThrowPermissionDeniedf(parent error, id, format string, a ...interface{}) error

func ThrowPreconditionFailed

func ThrowPreconditionFailed(parent error, id, message string) error

func ThrowPreconditionFailedf

func ThrowPreconditionFailedf(parent error, id, format string, a ...interface{}) error

func ThrowResourceExhausted

func ThrowResourceExhausted(parent error, id, message string) error

func ThrowResourceExhaustedf

func ThrowResourceExhaustedf(parent error, id, format string, a ...interface{}) error

func ThrowUnauthenticated

func ThrowUnauthenticated(parent error, id, message string) error

func ThrowUnauthenticatedf

func ThrowUnauthenticatedf(parent error, id, format string, a ...interface{}) error

func ThrowUnavailable

func ThrowUnavailable(parent error, id, message string) error

func ThrowUnavailablef

func ThrowUnavailablef(parent error, id, format string, a ...interface{}) error

func ThrowUnimplemented

func ThrowUnimplemented(parent error, id, message string) error

func ThrowUnimplementedf

func ThrowUnimplementedf(parent error, id, format string, a ...interface{}) error

func ThrowUnknown

func ThrowUnknown(parent error, id, message string) error

func ThrowUnknownf

func ThrowUnknownf(parent error, id, format string, a ...interface{}) error

Types

type AlreadyExists

type AlreadyExists interface {
	error
	IsAlreadyExists()
}

type AlreadyExistsError

type AlreadyExistsError struct {
	*Zerror
}

func (*AlreadyExistsError) Is

func (err *AlreadyExistsError) Is(target error) bool

func (*AlreadyExistsError) IsAlreadyExists

func (err *AlreadyExistsError) IsAlreadyExists()

func (*AlreadyExistsError) Unwrap

func (err *AlreadyExistsError) Unwrap() error

type DeadlineExceeded

type DeadlineExceeded interface {
	error
	IsDeadlineExceeded()
}

type DeadlineExceededError

type DeadlineExceededError struct {
	*Zerror
}

func (*DeadlineExceededError) Is

func (err *DeadlineExceededError) Is(target error) bool

func (*DeadlineExceededError) IsDeadlineExceeded

func (err *DeadlineExceededError) IsDeadlineExceeded()

func (*DeadlineExceededError) Unwrap

func (err *DeadlineExceededError) Unwrap() error

type Error

type Error interface {
	GetParent() error
	GetMessage() string
	SetMessage(string)
	GetID() string
}

Error is a stdlib error extension. It contains parameters to identify errors through all application layers

type Internal

type Internal interface {
	error
	IsInternal()
}

type InternalError

type InternalError struct {
	*Zerror
}

func (*InternalError) Is

func (err *InternalError) Is(target error) bool

func (*InternalError) IsInternal

func (err *InternalError) IsInternal()

func (*InternalError) Unwrap

func (err *InternalError) Unwrap() error

type InvalidArgument

type InvalidArgument interface {
	error
	IsInvalidArgument()
}

type InvalidArgumentError

type InvalidArgumentError struct {
	*Zerror
}

func (*InvalidArgumentError) Is

func (err *InvalidArgumentError) Is(target error) bool

func (*InvalidArgumentError) IsInvalidArgument

func (err *InvalidArgumentError) IsInvalidArgument()

func (*InvalidArgumentError) Unwrap

func (err *InvalidArgumentError) Unwrap() error

type NotFound

type NotFound interface {
	error
	IsNotFound()
}

type NotFoundError

type NotFoundError struct {
	*Zerror
}

func (*NotFoundError) Is

func (err *NotFoundError) Is(target error) bool

func (*NotFoundError) IsNotFound

func (err *NotFoundError) IsNotFound()

func (*NotFoundError) Unwrap

func (err *NotFoundError) Unwrap() error

type PermissionDenied

type PermissionDenied interface {
	error
	IsPermissionDenied()
}

type PermissionDeniedError

type PermissionDeniedError struct {
	*Zerror
}

func (*PermissionDeniedError) Is

func (err *PermissionDeniedError) Is(target error) bool

func (*PermissionDeniedError) IsPermissionDenied

func (err *PermissionDeniedError) IsPermissionDenied()

func (*PermissionDeniedError) Unwrap

func (err *PermissionDeniedError) Unwrap() error

type PreconditionFailed

type PreconditionFailed interface {
	error
	IsPreconditionFailed()
}

type PreconditionFailedError

type PreconditionFailedError struct {
	*Zerror
}

func (*PreconditionFailedError) Is

func (err *PreconditionFailedError) Is(target error) bool

func (*PreconditionFailedError) IsPreconditionFailed

func (err *PreconditionFailedError) IsPreconditionFailed()

func (*PreconditionFailedError) Unwrap

func (err *PreconditionFailedError) Unwrap() error

type ResourceExhausted

type ResourceExhausted interface {
	error
	IsResourceExhausted()
}

type ResourceExhaustedError

type ResourceExhaustedError struct {
	*Zerror
}

func (*ResourceExhaustedError) Is

func (err *ResourceExhaustedError) Is(target error) bool

func (*ResourceExhaustedError) IsResourceExhausted

func (err *ResourceExhaustedError) IsResourceExhausted()

func (*ResourceExhaustedError) Unwrap

func (err *ResourceExhaustedError) Unwrap() error

type Unauthenticated

type Unauthenticated interface {
	error
	IsUnauthenticated()
}

type UnauthenticatedError

type UnauthenticatedError struct {
	*Zerror
}

func (*UnauthenticatedError) Is

func (err *UnauthenticatedError) Is(target error) bool

func (*UnauthenticatedError) IsUnauthenticated

func (err *UnauthenticatedError) IsUnauthenticated()

func (*UnauthenticatedError) Unwrap

func (err *UnauthenticatedError) Unwrap() error

type Unavailable

type Unavailable interface {
	error
	IsUnavailable()
}

type UnavailableError

type UnavailableError struct {
	*Zerror
}

func (*UnavailableError) Is

func (err *UnavailableError) Is(target error) bool

func (*UnavailableError) IsUnavailable

func (err *UnavailableError) IsUnavailable()

func (*UnavailableError) Unwrap

func (err *UnavailableError) Unwrap() error

type Unimplemented

type Unimplemented interface {
	error
	IsUnimplemented()
}

type UnimplementedError

type UnimplementedError struct {
	*Zerror
}

func (*UnimplementedError) Is

func (err *UnimplementedError) Is(target error) bool

func (*UnimplementedError) IsUnimplemented

func (err *UnimplementedError) IsUnimplemented()

func (*UnimplementedError) Unwrap

func (err *UnimplementedError) Unwrap() error

type Unknown

type Unknown interface {
	error
	IsUnknown()
}

type UnknownError

type UnknownError struct {
	*Zerror
}

func (*UnknownError) Is

func (err *UnknownError) Is(target error) bool

func (*UnknownError) IsUnknown

func (err *UnknownError) IsUnknown()

func (*UnknownError) Unwrap

func (err *UnknownError) Unwrap() error

type Zerror

type Zerror struct {
	Parent  error
	Message string
	ID      string
}

func CreateZnowError

func CreateZnowError(parent error, id, message string) *Zerror

func (*Zerror) As

func (err *Zerror) As(target interface{}) bool

func (*Zerror) Error

func (err *Zerror) Error() string

func (*Zerror) GetID

func (err *Zerror) GetID() string

func (*Zerror) GetMessage

func (err *Zerror) GetMessage() string

func (*Zerror) GetParent

func (err *Zerror) GetParent() error

func (*Zerror) Is

func (err *Zerror) Is(target error) bool

func (*Zerror) SetMessage

func (err *Zerror) SetMessage(msg string)

func (*Zerror) Unwrap

func (err *Zerror) Unwrap() error

Directories

Path Synopsis
go generate
go generate

Jump to

Keyboard shortcuts

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