Skip to content

Commit

Permalink
Error Deserializers – Revision 2: Add support for different error cod…
Browse files Browse the repository at this point in the history
…e sanitization.
  • Loading branch information
nathanhit committed Sep 10, 2024
1 parent 4c101ad commit da7abb4
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,21 @@ func getProtocolErrorInfo(payload []byte) (typ, msg string, v $value:T, err erro
if jtyp, ok := jv["__type"]; ok {
typ = jtyp.(string)
} else if jtyp, ok := jv["code"]; ok {
typ = jtyp.(string)
}
// TODO: Add in Header Check for "x-amzn-errortype"
hashIndex, colonIndex := 0, len(typ)-1
for idx := 0; idx < len(typ); idx++ {
if typ[idx] == '#' && hashIndex == 0 {
hashIndex = idx
}
if typ[idx] == ':' && colonIndex == len(typ)-1 {
colonIndex = idx
}
}
typ = typ[hashIndex:colonIndex+1]
if jmsg, ok := jv["message"]; ok {
msg = jmsg.(string)
Expand Down

0 comments on commit da7abb4

Please sign in to comment.