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)
| 491 | // ConsoleURL, etc.) for known Lark codes; unknown codes still surface as |
| 492 | // *errs.APIError{Subtype: unknown}. |
| 493 | func (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 | } |
no test coverage detected