github.com/kamalshkeir/kencoding@v0.0.2-0.20230409043843-44b609a0475a/proto/error.go (about)

     1  package proto
     2  
     3  import (
     4  	"errors"
     5  	"fmt"
     6  )
     7  
     8  var (
     9  	ErrWireTypeUnknown = errors.New("unknown wire type")
    10  )
    11  
    12  type UnmarshalFieldError struct {
    13  	FieldNumer int
    14  	WireType   int
    15  	Err        error
    16  }
    17  
    18  func (e *UnmarshalFieldError) Error() string {
    19  	return fmt.Sprintf("field number %d with wire type %d: %v", e.FieldNumer, e.WireType, e.Err)
    20  }
    21  
    22  func (e *UnmarshalFieldError) Unwrap() error { return e.Err }
    23  
    24  func fieldError(f fieldNumber, t wireType, err error) error {
    25  	return &UnmarshalFieldError{
    26  		FieldNumer: int(f),
    27  		WireType:   int(t),
    28  		Err:        err,
    29  	}
    30  }