func marshalError(f string, c ErrorCode, desc string, v interface{}) *MarshalError {
	e := &MarshalError{ErrorCode: c, Func: f, Description: desc}
	switch t := v.(type) {
	case []byte:
		slice := make([]byte, len(t))
		copy(slice, t)
		e.Value = slice
	default:
		e.Value = v
	}
	return e
}
marshalError creates an error given a set of arguments and will copy byte
slices into the Value field since they might otherwise be changed from from
the original value.
package xdr
import (
	"fmt"
)
type ErrorCode int
const (
	ErrBadArguments ErrorCode = iota
	ErrUnsupportedType
	ErrUnexpectedEnd
	ErrBadEnumValue
	ErrNotSettable
	ErrOverflow
	ErrNilInterface
)
var errorCodeStrings = map[ErrorCode]string{
	ErrBadArguments:    "ErrBadArguments",
	ErrUnsupportedType: "ErrUnsupportedType",
	ErrUnexpectedEnd:   "ErrUnexpectedEnd",
	ErrBadEnumValue:    "ErrBadEnumValue",
	ErrNotSettable:     "ErrNotSettable",
	ErrOverflow:        "ErrOverflow",
	ErrNilInterface:    "ErrNilInterface",
}
func (e ErrorCode) String() string {
	if s := errorCodeStrings[e]; s != "" {
		return s
	}
	return fmt.Sprintf("Unknown ErrorCode (%d)", e)
}
type UnmarshalError struct {
	ErrorCode   ErrorCode    
	Func        string       
	Value       interface{}  
	Description string       
}
func (e *UnmarshalError) Error() string {
	switch e.ErrorCode {
	case ErrUnexpectedEnd, ErrBadEnumValue, ErrOverflow:
		return fmt.Sprintf("xdr:%s: %s - read: '%v'", e.Func, e.Description, e.Value)
	}
	return fmt.Sprintf("xdr:%s: %s", e.Func, e.Description)
}
func unmarshalError(f string, c ErrorCode, desc string, v interface{}) *UnmarshalError {
	e := &UnmarshalError{ErrorCode: c, Func: f, Description: desc}
	switch t := v.(type) {
	case []byte:
		slice := make([]byte, len(t))
		copy(slice, t)
		e.Value = slice
	default:
		e.Value = v
	}
	return e
}
type MarshalError struct {
	ErrorCode   ErrorCode    
	Func        string       
	Value       interface{}  
	Description string       
}
func (e *MarshalError) Error() string {
	switch e.ErrorCode {
	case ErrUnexpectedEnd, ErrBadEnumValue, ErrOverflow:
		return fmt.Sprintf("xdr:%s: %s - read: '%v'", e.Func, e.Description, e.Value)
	}
	return fmt.Sprintf("xdr:%s: %s", e.Func, e.Description)
}