all: refactor attributes

This commit is contained in:
Aleksandr Razumov
2017-02-11 05:23:49 +03:00
parent 3ec51bf758
commit fba9f6b02d
21 changed files with 1048 additions and 1107 deletions

View File

@@ -15,6 +15,12 @@ type DecodeErr struct {
Message string
}
// IsInvalidCookie returns true if error means that magic cookie
// value is invalid.
func (e DecodeErr) IsInvalidCookie() bool {
return e.Place == DecodeErrPlace{"message", "cookie"}
}
// IsPlaceParent reports if error place parent is p.
func (e DecodeErr) IsPlaceParent(p string) bool {
return e.Place.Parent == p
@@ -50,3 +56,8 @@ func newDecodeErr(parent, children, message string) *DecodeErr {
Message: message,
}
}
// TODO(ar): rewrite errors to be more precise.
func newAttrDecodeErr(children, message string) *DecodeErr {
return newDecodeErr("attribute", children, message)
}