Parcourir la source

withMessage错误Error隐藏内部error错误

jys il y a 11 mois
Parent
commit
a4a3fe0556
1 fichiers modifiés avec 2 ajouts et 2 suppressions
  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())
 			}