Module shell (3)

This commit is contained in:
Benjamin VAUDOUR 2023-10-07 21:13:39 +02:00
parent 8e5ad41b11
commit 75f0c1350b
13 changed files with 2644 additions and 0 deletions

View file

@ -0,0 +1,29 @@
package errors
import (
"fmt"
)
type Error struct {
msg string
code int
}
func (err *Error) Error() string {
return err.msg
}
func (err *Error) Code() int {
return err.code
}
func New(code int, msg string) *Error {
return &Error{
msg: msg,
code: code,
}
}
func Newf(code int, tmpl string, args ...any) *Error {
return New(code, fmt.Sprintf(tmpl, args...))
}