diff options
Diffstat (limited to 'vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/unmarshal.go')
-rw-r--r-- | vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/unmarshal.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/unmarshal.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/unmarshal.go index ff1ef68..7108d38 100644 --- a/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/unmarshal.go +++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/unmarshal.go | |||
@@ -1,6 +1,7 @@ | |||
1 | package xmlutil | 1 | package xmlutil |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "bytes" | ||
4 | "encoding/base64" | 5 | "encoding/base64" |
5 | "encoding/xml" | 6 | "encoding/xml" |
6 | "fmt" | 7 | "fmt" |
@@ -10,9 +11,27 @@ import ( | |||
10 | "strings" | 11 | "strings" |
11 | "time" | 12 | "time" |
12 | 13 | ||
14 | "github.com/aws/aws-sdk-go/aws/awserr" | ||
13 | "github.com/aws/aws-sdk-go/private/protocol" | 15 | "github.com/aws/aws-sdk-go/private/protocol" |
14 | ) | 16 | ) |
15 | 17 | ||
18 | // UnmarshalXMLError unmarshals the XML error from the stream into the value | ||
19 | // type specified. The value must be a pointer. If the message fails to | ||
20 | // unmarshal, the message content will be included in the returned error as a | ||
21 | // awserr.UnmarshalError. | ||
22 | func UnmarshalXMLError(v interface{}, stream io.Reader) error { | ||
23 | var errBuf bytes.Buffer | ||
24 | body := io.TeeReader(stream, &errBuf) | ||
25 | |||
26 | err := xml.NewDecoder(body).Decode(v) | ||
27 | if err != nil && err != io.EOF { | ||
28 | return awserr.NewUnmarshalError(err, | ||
29 | "failed to unmarshal error message", errBuf.Bytes()) | ||
30 | } | ||
31 | |||
32 | return nil | ||
33 | } | ||
34 | |||
16 | // UnmarshalXML deserializes an xml.Decoder into the container v. V | 35 | // UnmarshalXML deserializes an xml.Decoder into the container v. V |
17 | // needs to match the shape of the XML expected to be decoded. | 36 | // needs to match the shape of the XML expected to be decoded. |
18 | // If the shape doesn't match unmarshaling will fail. | 37 | // If the shape doesn't match unmarshaling will fail. |