Refactor domain error to use errorId (#790)
* Refactor domain error to use errorId * Wrap accepts options and uses New internally
This commit is contained in:
1 parent
b8a5b9adf1
commit
d30dd0ff64
8 files changed
+184
-103
No files matched your search
@@ -16,10 +16,10 @@ func T(args ...interface{}) *Template {
|
||||
switch arg := a.(type) {
|
||||
case Code:
|
||||
t.Code = arg
|
||||
case ErrorId:
|
||||
t.ErrorId = arg
|
||||
case string:
|
||||
t.Msg = arg
|
||||
case Op:
|
||||
t.Op = arg
|
||||
case *Err: // order is important, this match must before "case error:"
|
||||
c := *arg
|
||||
t.Wrapped = &c
|
||||
@@ -78,7 +78,7 @@ func Match(t *Template, err error) bool {
|
||||
if t.Msg != "" && t.Msg != e.Msg {
|
||||
return false
|
||||
}
|
||||
if t.Op != "" && t.Op != e.Op {
|
||||
if t.ErrorId != "" && t.ErrorId != e.ErrorId {
|
||||
return false
|
||||
}
|
||||
if t.Kind != Other && t.Info().Kind != e.Info().Kind {
|
||||
|
||||
Reference in new issue
Block a user