MCPcopy Index your code
hub / github.com/docker/docker-agent / parseProviderError

Function parseProviderError

pkg/modelerrors/modelerrors.go:682–699  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

680//
681// Returns "" when no JSON body is present or it has no recognised fields.
682func 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//

Callers 1

ErrorMethod · 0.85

Calls 2

firstJSONObjectFunction · 0.85
formatProviderErrorFunction · 0.85

Tested by

no test coverage detected