Merge pull request #6 from nogoegst/undup-status-message

Do not print status message twice
This commit is contained in:
Yawning Angel 2016-10-27 18:45:32 +00:00 committed by GitHub
commit 38b4676028
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)
}