// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT

package stun

import 

// DecodeErr records an error and place when it is occurred.
//
//nolint:errname
type DecodeErr struct {
	Place   DecodeErrPlace
	Message string
}

// IsInvalidCookie returns true if error means that magic cookie
// value is invalid.
func ( DecodeErr) () bool {
	return .Place == DecodeErrPlace{"message", "cookie"}
}

// IsPlaceParent reports if error place parent is p.
func ( DecodeErr) ( string) bool {
	return .Place.Parent == 
}

// IsPlaceChildren reports if error place children is c.
func ( DecodeErr) ( string) bool {
	return .Place.Children == 
}

// IsPlace reports if error place is p.
func ( DecodeErr) ( DecodeErrPlace) bool {
	return .Place == 
}

// DecodeErrPlace records a place where error is occurred.
type DecodeErrPlace struct {
	Parent   string
	Children string
}

func ( DecodeErrPlace) () string {
	return .Parent + "/" + .Children
}

func ( DecodeErr) () string {
	return "BadFormat for " + .Place.String() + ": " + .Message
}

func newDecodeErr(, ,  string) *DecodeErr {
	return &DecodeErr{
		Place:   DecodeErrPlace{Parent: , Children: },
		Message: ,
	}
}

func newAttrDecodeErr(,  string) *DecodeErr {
	return newDecodeErr("attribute", , )
}

// ErrAttributeSizeInvalid means that decoded attribute size is invalid.
var ErrAttributeSizeInvalid = errors.New("attribute size is invalid")

// ErrAttributeSizeOverflow means that decoded attribute size is too big.
var ErrAttributeSizeOverflow = errors.New("attribute size overflow")