MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / unwrap

Function unwrap

packages/server-e2e/src/envelope.ts:38–47  ·  view source on GitHub ↗
(envelope: Envelope<T>)

Source from the content-addressed store, hash-verified

36 * `null` — callers asking for a non-nullable type should narrow).
37 */
38export function unwrap<T>(envelope: Envelope<T>): T {
39 if (envelope.code !== 0) throw new EnvelopeError(envelope);
40 if (envelope.data === null) {
41 // `code: 0 + data: null` is reserved for "no body" success envelopes; the
42 // current server surface always returns a non-null data on success, so
43 // surface this as a hard error rather than silently returning `null`.
44 throw new EnvelopeError({ ...envelope, code: 50001, msg: 'success envelope had null data' });
45 }
46 return envelope.data;
47}

Callers 2

requestMethod · 0.85
formRequestMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected