parseProviderError returns a focused details line lifted from an SDK error message of the form " ": [ (Request-ID: )] Returns "" when no JSON body is present or it has no recognised fields.
(s string)
| 680 | // |
| 681 | // Returns "" when no JSON body is present or it has no recognised fields. |
| 682 | func parseProviderError(s string) string { |
| 683 | body := firstJSONObject(s) |
| 684 | if body == nil { |
| 685 | return "" |
| 686 | } |
| 687 | var parsed providerErrorBody |
| 688 | if json.Unmarshal(body, &parsed) != nil { |
| 689 | return "" |
| 690 | } |
| 691 | details := formatProviderError(&parsed) |
| 692 | if details == "" { |
| 693 | return "" |
| 694 | } |
| 695 | if m := requestIDRegex.FindStringSubmatch(s); len(m) >= 2 { |
| 696 | details += " (Request-ID: " + m[1] + ")" |
| 697 | } |
| 698 | return details |
| 699 | } |
| 700 | |
| 701 | // formatProviderError renders a parsed body as |
| 702 | // |
no test coverage detected