package xml
import (
)
type ErrorComponents struct {
Code string
Message string
}
func ( io.Reader, bool) (ErrorComponents, error) {
if {
var noWrappedErrorResponse
if := xml.NewDecoder().Decode(&); != nil && != io.EOF {
return ErrorComponents{}, fmt.Errorf("error while deserializing xml error response: %w", )
}
return ErrorComponents{
Code: .Code,
Message: .Message,
}, nil
}
var wrappedErrorResponse
if := xml.NewDecoder().Decode(&); != nil && != io.EOF {
return ErrorComponents{}, fmt.Errorf("error while deserializing xml error response: %w", )
}
return ErrorComponents{
Code: .Code,
Message: .Message,
}, nil
}
type noWrappedErrorResponse struct {
Code string `xml:"Code"`
Message string `xml:"Message"`
}
type wrappedErrorResponse struct {
Code string `xml:"Error>Code"`
Message string `xml:"Error>Message"`
}