MCPcopy Create free account
hub / github.com/larksuite/cli / decodeErrorEnvelope

Function decodeErrorEnvelope

cmd/root_test.go:371–382  ·  view source on GitHub ↗

decodeErrorEnvelope unmarshals a typed error envelope and returns its top-level "error" object, failing the test if the shape is unexpected.

(t *testing.T, raw []byte)

Source from the content-addressed store, hash-verified

369// decodeErrorEnvelope unmarshals a typed error envelope and returns its
370// top-level "error" object, failing the test if the shape is unexpected.
371func decodeErrorEnvelope(t *testing.T, raw []byte) map[string]any {
372 t.Helper()
373 var env map[string]any
374 if err := json.Unmarshal(raw, &env); err != nil {
375 t.Fatalf("envelope is not valid JSON: %v\n%s", err, raw)
376 }
377 errObj, ok := env["error"].(map[string]any)
378 if !ok {
379 t.Fatalf("envelope missing top-level error object: %s", raw)
380 }
381 return errObj
382}
383
384// TestHandleRootError_NoDeprecationTypesUsageError pins that a residual cobra
385// usage error (missing required flag) is typed as invalid_argument with exit 2

Calls

no outgoing calls

Tested by

no test coverage detected