errgo

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2022 License: MIT Imports: 1 Imported by: 1

README

errgo

go.dev reference GitHub go.mod Go version GitHub tag (latest SemVer) GitHub license

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrGo

type ErrGo interface {
	Error() error
	GetError() error
	GetCode() string
	GetMessage() string
	GetStatus() int
}

func New

func New(code, message string) ErrGo

New generates new errgo that implements ErrGo.

func NewWithStatus added in v1.1.0

func NewWithStatus(code, message string, status int) ErrGo

NewWithStatus generates new errgo with status that implements ErrGo.

Jump to

Keyboard shortcuts

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