Help us shape the future of Go! Take the 2026 Go Developer Survey

exception

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: Apache-2.0 Imports: 11 Imported by: 47

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Mode = "production"

Mode the mode of the application

Functions

func Catch added in v0.8.0

func Catch(recovered interface{}, err ...error) error

Catch Exception catch and recovered

func CatchDebug

func CatchDebug()

CatchDebug Catch the exception and print debug info

func CatchPrint

func CatchPrint()

CatchPrint Catch the exception and print it

func DebugPrint added in v1.0.0

func DebugPrint(err error, message string, args ...interface{})

DebugPrint print the message only in development mode

func GetWriter added in v1.0.0

func GetWriter() io.Writer

GetWriter returns the current output target.

func SetWriter added in v1.0.0

func SetWriter(w io.Writer)

SetWriter replaces the output target for debug/exception messages. Pass nil to reset to os.Stdout.

func Trim added in v1.0.0

func Trim(err error) string

Trim the exception message

Types

type Exception

type Exception struct {
	Message string      `json:"message"`
	Code    int         `json:"code"`
	Context interface{} `json:"context"`
}

Exception the Exception type

func Err

func Err(err error, code int) *Exception

Err Create an exception instance from the error

func New

func New(message string, code int, args ...interface{}) *Exception

New Create a new exception instance

func (*Exception) Ctx

func (exception *Exception) Ctx(context interface{}) *Exception

Ctx Add the context for the exception.

func (Exception) Print

func (exception Exception) Print()

Print print the exception

func (Exception) String

func (exception Exception) String() string

String interface

func (Exception) Throw

func (exception Exception) Throw()

Throw Throw the exception and terminal progress.

Jump to

Keyboard shortcuts

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