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

Function formatProviderError

pkg/modelerrors/modelerrors.go:707–730  ·  view source on GitHub ↗

formatProviderError renders a parsed body as : (code=..., param=..., status=...) Falls back to the top-level `message` field for minimal/proxy bodies. Returns "" when the body has nothing useful.

(p *providerErrorBody)

Source from the content-addressed store, hash-verified

705// Falls back to the top-level `message` field for minimal/proxy bodies.
706// Returns "" when the body has nothing useful.
707func formatProviderError(p *providerErrorBody) string {
708 if p.Error == nil || p.Error.Message == "" {
709 return p.Message
710 }
711 msg := p.Error.Message
712 if p.Error.Type != "" {
713 msg = p.Error.Type + ": " + msg
714 }
715
716 var meta []string
717 if code := scalarString(p.Error.Code); code != "" {
718 meta = append(meta, "code="+code)
719 }
720 if param := scalarString(p.Error.Param); param != "" {
721 meta = append(meta, "param="+param)
722 }
723 if p.Error.Status != "" && !strings.EqualFold(p.Error.Status, p.Error.Type) {
724 meta = append(meta, "status="+p.Error.Status)
725 }
726 if len(meta) > 0 {
727 msg += " (" + strings.Join(meta, ", ") + ")"
728 }
729 return msg
730}
731
732// firstJSONObject returns the first complete JSON object found in s, or nil.
733// encoding/json handles escaped quotes and braces inside string values.

Callers 1

parseProviderErrorFunction · 0.85

Calls 1

scalarStringFunction · 0.85

Tested by

no test coverage detected