MCPcopy Index your code
hub / github.com/larksuite/cli / WrapJSONResponseParseError

Function WrapJSONResponseParseError

internal/client/api_errors.go:56–68  ·  view source on GitHub ↗

WrapJSONResponseParseError lifts a response-layer JSON parse failure into *errs.InternalError{Subtype: SubtypeInvalidResponse}. Empty body, malformed JSON, and mid-stream EOFs all collapse to this single shape.

(err error, body []byte)

Source from the content-addressed store, hash-verified

54// *errs.InternalError{Subtype: SubtypeInvalidResponse}. Empty body, malformed
55// JSON, and mid-stream EOFs all collapse to this single shape.
56func WrapJSONResponseParseError(err error, body []byte) error {
57 if err == nil {
58 return nil
59 }
60
61 var e *errs.InternalError
62 if len(bytes.TrimSpace(body)) == 0 {
63 e = errs.NewInternalError(errs.SubtypeInvalidResponse, "API returned an empty JSON response body")
64 } else {
65 e = errs.NewInternalError(errs.SubtypeInvalidResponse, "API returned an invalid JSON response: %v", err)
66 }
67 return e.WithHint("%s", rawAPIJSONHint).WithCause(err)
68}
69
70// classifyNetworkSubtype maps an error chain to one of the network subtypes,
71// falling back to SubtypeNetworkTransport. Timeout is checked first because

Calls 3

WithHintMethod · 0.95
NewInternalErrorFunction · 0.92
WithCauseMethod · 0.45