Do not print status message twice

This commit is contained in:
Ivan Markin 2016-10-26 19:05:36 +00:00
parent c694c91ead
commit 9bea501013
1 changed files with 3 additions and 1 deletions

View File

@ -9,6 +9,7 @@ package bulb
import (
"fmt"
"strings"
"net/textproto"
)
@ -61,7 +62,8 @@ func statusCodeToError(code int, reply string) *textproto.Error {
err := new(textproto.Error)
err.Code = code
if msg, ok := statusCodeStringMap[code]; ok {
err.Msg = fmt.Sprintf("%s: %s", msg, reply)
trimmedReply := strings.TrimSpace(strings.TrimPrefix(reply, msg))
err.Msg = fmt.Sprintf("%s: %s", msg, trimmedReply)
} else {
err.Msg = fmt.Sprintf("Unknown status code (%03d): %s", code, reply)
}