Commit 4db93ab5 authored by Daniel Martí's avatar Daniel Martí

use %q in error strings

%q is superior to the manually quoted "%s", since it will properly
escape the inner string when quoting. For example:

	"here goes a double quote: \" "

Even if this does not matter in practice, using %q is easier too.
parent 6796504d
......@@ -68,7 +68,7 @@ type ErrRepeatedMapKey struct {
}
func (e ErrRepeatedMapKey) Error() string {
return fmt.Sprintf("cannot repeat map key (\"%s\")", e.Key)
return fmt.Sprintf("cannot repeat map key %q", e.Key)
}
// ErrInvalidKey indicates a key is invalid for some reason.
......@@ -94,9 +94,9 @@ type ErrInvalidKey struct {
func (e ErrInvalidKey) Error() string {
if e.Reason == nil {
return fmt.Sprintf("invalid key for map %s: \"%s\": no such field", e.TypeName, e.Key)
return fmt.Sprintf("invalid key for map %s: %q: no such field", e.TypeName, e.Key)
} else {
return fmt.Sprintf("invalid key for map %s: \"%s\": %s", e.TypeName, e.Key, e.Reason)
return fmt.Sprintf("invalid key for map %s: %q: %s", e.TypeName, e.Key, e.Reason)
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment