errgo
errgo provides custom interface for error errgo.ErrGo
with code
and message
as a standard.
Getting started
Installation
You can use the go get
method:
go get github.com/dalikewara/errgo
Usage
type ErrGo interface {
Error() error
GetError() error
GetCode() string
GetMessage() string
GetStatus() int
}
Generate new error
err := errgo.New("01", "data not found")
fmt.Println(err.GetCode()) // 01
fmt.Println(err.GetMessage()) // data not found
fmt.Println(err.GetError().Error()) // 01||data not found
Generate new error with status
err := errgo.NewWithStatus("01", "data not found", 200)
fmt.Println(err.GetCode()) // 01
fmt.Println(err.GetMessage()) // data not found
fmt.Println(err.GetStatus()) // 200
fmt.Println(err.GetError().Error()) // 01||data not found
Release
Changelog
Read at CHANGELOG.md
Credits
Copyright © 2022 Dali Kewara
License
MIT License