...
1 package apperror
2
3 import "fmt"
4
5
6
7 type AppError struct {
8 code string
9 message string
10 err error
11 }
12
13
14 func New(err error, code string, msg string) *AppError {
15 return &AppError{
16 code: code,
17 message: msg,
18 err: err,
19 }
20 }
21
22 func (e AppError) Error() string {
23 return fmt.Sprintf("%s <%s>. %v", e.message, e.code, e.err.Error())
24 }
25
26 func (e AppError) Unwrap() error {
27 return e.err
28 }
29
30 func (e AppError) ErrorCode() string {
31 return e.code
32 }
33
View as plain text