noggin

formatSuccess and formatError

The canonical builders for JsonEnvelope values. Hosts that hand-craft envelopes would drift on the version field; these functions stamp envelopeVersion and unwrap engine NogginErrors into the wire payload for you.

formatSuccess()

function formatSuccess<T>(opts: {
  data?: T;
  verb?: string;
}): SuccessEnvelope<T>;

Type Parameters

Type Parameter
T

Parameters

ParameterType
opts{ data?: T; verb?: string; }
opts.data?T
opts.verb?string

Returns

SuccessEnvelope<T>

formatError()

function formatError(opts: {
  error: unknown;
  verb?: string;
}): ErrorEnvelope;

Parameters

ParameterType
opts{ error: unknown; verb?: string; }
opts.errorunknown
opts.verb?string

Returns

ErrorEnvelope