error.go
func (e *errorT) Error() string {
	var (
		text     = strings.TrimSpace(e.text)
		prevText []byte
		prevList List
	)
	if e.err != nil {
		input := []byte(e.err.Error())
		prevText, prevList = Parse(input)
		if len(prevText) == 0 && len(prevList) > 0 {
			// The previous message consists only of key/value
			// pairs. Search for a key indicating the message.
			i := 0
			newLen := len(prevList)
			for ; i < len(prevList); i += 2 {
				key, _ := prevList[i].(string)
				if key == "msg" {
					if value, ok := prevList[i+1].(string); ok {
						prevText = []byte(value)
						newLen -= 2
						break
					}
				}
			}
			for ; i < len(prevList)-2; i += 2 {
				prevList[i] = prevList[i+2]
				prevList[i+1] = prevList[i+3]
			}
			prevList = prevList[:newLen]
		}
	}

	buf := pool.AllocBuffer()
	defer pool.ReleaseBuffer(buf)

	if len(text) > 0 {
		buf.WriteString(text)
		if len(prevText) > 0 {
			buf.WriteString(": ")
		}
	}
	buf.Write(prevText)

	list := dedup(e.list, prevList, e.ctxlist)
	if len(list) > 0 {
		if buf.Len() > 0 {
			buf.WriteRune(' ')
		}
		list.writeToBuffer(buf)
	}

	return buf.String()
}
func (e *errorT) Error() string {
	var (
		text     = strings.TrimSpace(e.text)
		prevText []byte
		prevList List
	)
	if e.err != nil {
		input := []byte(e.err.Error())
		prevText, prevList = Parse(input)
		if len(prevText) == 0 && len(prevList) > 0 {
			// The previous message consists only of key/value
			// pairs. Search for a key indicating the message.
			i := 0
			newLen := len(prevList)
			for ; i < len(prevList); i += 2 {
				key, _ := prevList[i].(string)
				if key == "msg" {
					if value, ok := prevList[i+1].(string); ok {
						prevText = []byte(value)
						newLen -= 2
						break
					}
				}
			}
			for ; i < len(prevList)-2; i += 2 {
				prevList[i] = prevList[i+2]
				prevList[i+1] = prevList[i+3]
			}
			prevList = prevList[:newLen]
		}
	}

	buf := pool.AllocBuffer()
	defer pool.ReleaseBuffer(buf)

	if len(text) > 0 {
		buf.WriteString(text)
		if len(prevText) > 0 {
			buf.WriteString(": ")
		}
	}
	buf.Write(prevText)

	list := dedup(e.list, prevList, e.ctxlist)
	if len(list) > 0 {
		if buf.Len() > 0 {
			buf.WriteRune(' ')
		}
		list.writeToBuffer(buf)
	}

	return buf.String()
}
// Error implements the error interface.
//
// The string returned prints the error text of this error
// any any wrapped errors, each separated by a colon and a space (": ").
// After the error message (or messages) comes the key/value pairs.
// The resulting string can be parsed with the Parse function.