Skip to content

Commit

Permalink
Error() method includes the code.
Browse files Browse the repository at this point in the history
Message() method returns the string only. This gets used to optionally get the message without the code.
  • Loading branch information
jjeffery committed Jan 20, 2017
1 parent 8ecd1fa commit 53842d4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions errkind.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
package errkind

import (
"fmt"
"net/http"
"strings"

Expand Down Expand Up @@ -203,6 +204,13 @@ type publicStatusCodeError struct {
}

func (s publicStatusCodeError) Error() string {
if strings.ContainsAny(s.code, "\n\r\t \"'") {
return fmt.Sprintf("%s code=%q", s.message, s.code)
}
return fmt.Sprintf("%s code=%s", s.message, s.code)
}

func (s publicStatusCodeError) Message() string {
return s.message
}

Expand Down

0 comments on commit 53842d4

Please sign in to comment.