MCPcopy
hub / github.com/larksuite/cli / CheckResponse

Method CheckResponse

internal/client/client.go:493–507  ·  view source on GitHub ↗

CheckResponse inspects a Lark API response for business-level errors (non-zero code) and routes the result through errclass.BuildAPIError so the wire envelope carries the canonical Category/Subtype + identity-aware extension fields (MissingScopes, ConsoleURL, etc.) for known Lark codes; unknown code

(result interface{}, identity core.Identity)

Source from the content-addressed store, hash-verified

491// ConsoleURL, etc.) for known Lark codes; unknown codes still surface as
492// *errs.APIError{Subtype: unknown}.
493func (c *APIClient) CheckResponse(result interface{}, identity core.Identity) error {
494 resultMap, ok := result.(map[string]interface{})
495 if !ok || resultMap == nil {
496 return nil
497 }
498 if code, _ := util.ToFloat64(resultMap["code"]); code == 0 {
499 return nil
500 }
501 cc := errclass.ClassifyContext{Identity: string(identity)}
502 if c != nil && c.Config != nil {
503 cc.Brand = string(c.Config.Brand)
504 cc.AppID = c.Config.AppID
505 }
506 return errclass.BuildAPIError(resultMap, cc)
507}

Callers 3

HandleResponseFunction · 0.80
apiPaginateFunction · 0.80
CallAPIMethod · 0.80

Calls 2

ToFloat64Function · 0.92
BuildAPIErrorFunction · 0.92

Tested by

no test coverage detected