Browse Source

withMessage错误Error隐藏内部error错误

jys 11 months ago
parent
commit
a4a3fe0556
1 changed files with 2 additions and 2 deletions
  1. 2 2
      errors.go

+ 2 - 2
errors.go

@@ -60,14 +60,14 @@ type withMessage struct {
 	msg   string
 }
 
-func (w *withMessage) Error() string { return w.msg + ": " + w.cause.Error() }
+func (w *withMessage) Error() string { return w.msg }
 func (w *withMessage) Cause() error  { return w.cause }
 func (w *withMessage) Unwrap() error { return w.cause }
 func (w *withMessage) Format(s fmt.State, verb rune) {
 	switch verb {
 	case 'v':
 		if s.Flag('+') {
-			io.WriteString(s, w.msg+": ")
+			io.WriteString(s, w.msg+"\n")
 			if w.Cause() != nil {
 				fmt.Fprintf(s, "%+v", w.Cause())
 			}