mirror of
https://github.com/pion/stun.git
synced 2025-09-27 20:22:08 +08:00
all: refactor attributes
This commit is contained in:
11
errors.go
11
errors.go
@@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user