exception

package module
v0.0.0-...-ba79130 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: MIT Imports: 6 Imported by: 30

README

Exception

Go Reference Go Report Card

Package exception defines some common exceptions.

Installation

go get -u -v github.com/gopi-frame/exception

Import

import "github.com/gopi-frame/exception"

Exceptions

NoSuchMethodException

NoSuchMethodException is used to indicate no such method.

Example:

exception.NewNoSuchMethodException(new(Object), "method")
exception.NewUnexportedMethodException("method")
ArgumentException

ArgumentException is used to indicate invalid arguments.

Example:

exception.NewArgumentException("number", "-1", "number should be positive")
exception.NewEmptyArgumentException("number")
RangeException

RangeException is used to indicate invalid range.

Example:

exception.NewRangeException(1, 10)
TimeException

TimeException is used to indicate timeout.

Example:

exception.NewTimeException()
TypeException

TypeException is used to indicate invalid type.

Example:

exception.NewTypeException("Invalid type for parameter `number`")
UndefinedIndexException

UndefinedIndexException is used to indicate undefined index.

Example:

exception.NewUndefinedIndexException(10)
UnsupportedException

UnsupportedException is used to indicate unsupported operation.

Example:

exception.NewUnsupportedException("Unsupported operation")
ValueException

ValueException is mainly used to convert a non error type value to an Exception. Typically used in recover when a function panics a value instead of error.

Example:

exception.NewValueException("value")

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(messages ...string) ec.Throwable

func WithMessage

func WithMessage(err error, message string) ec.Throwable

WithMessage new exception

func Wrap

func Wrap(err error) ec.Throwable

Types

type ArgumentException

type ArgumentException struct {
	ec.Throwable
	// contains filtered or unexported fields
}

ArgumentException argument exception

func NewArgumentException

func NewArgumentException(name string, invalidValue any, messages ...string) *ArgumentException

NewArgumentException new argument exception

func NewEmptyArgumentException

func NewEmptyArgumentException(name string) *ArgumentException

NewEmptyArgumentException argument empty

func (ArgumentException) Unwrap

func (e ArgumentException) Unwrap() error

type NoSuchMethodException

type NoSuchMethodException struct {
	ec.Throwable
	// contains filtered or unexported fields
}

NoSuchMethodException no such method exception

func NewNoSuchMethodException

func NewNoSuchMethodException(receiver any, method string) *NoSuchMethodException

NewNoSuchMethodException new no such method exception

func NewUnexportedMethodException

func NewUnexportedMethodException(method string) *NoSuchMethodException

NewUnexportedMethodException new unexported method exception

func (NoSuchMethodException) Unwrap

func (e NoSuchMethodException) Unwrap() error

type RangeException

type RangeException struct {
	ec.Throwable
	// contains filtered or unexported fields
}

RangeException range exception

func NewRangeException

func NewRangeException(start int, end int) *RangeException

NewRangeException new range exception

func (*RangeException) Error

func (e *RangeException) Error() string

func (RangeException) Unwrap

func (e RangeException) Unwrap() error

type TimeoutException

type TimeoutException struct {
	ec.Throwable
}

TimeoutException timeout exception

func NewTimeoutException

func NewTimeoutException() *TimeoutException

NewTimeoutException new timeout exception

func (TimeoutException) Unwrap

func (e TimeoutException) Unwrap() error

type TypeException

type TypeException struct {
	ec.Throwable
}

TypeException type exception

func NewTypeException

func NewTypeException(message string) *TypeException

NewTypeException new type exception

func (TypeException) Unwrap

func (e TypeException) Unwrap() error

type UndefinedIndexException

type UndefinedIndexException struct {
	ArgumentException
}

func NewUndefinedIndexException

func NewUndefinedIndexException(index string) *UndefinedIndexException

func (UndefinedIndexException) Unwrap

func (e UndefinedIndexException) Unwrap() error

type UnsupportedException

type UnsupportedException struct {
	ec.Throwable
}

UnsupportedException unsupported exception

func NewUnsupportedException

func NewUnsupportedException(message string) *UnsupportedException

NewUnsupportedException new unsupported exception

type ValueException

type ValueException struct {
	ec.Throwable
	Value any
}

ValueException exception with value

func NewValueException

func NewValueException(v any) *ValueException

NewValueException new ValueException

Jump to

Keyboard shortcuts

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