Module shell (3)
This commit is contained in:
parent
8e5ad41b11
commit
75f0c1350b
13 changed files with 2644 additions and 0 deletions
29
shell/console/errors/error.go
Normal file
29
shell/console/errors/error.go
Normal 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...))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue