MCPcopy Create free account
hub / github.com/oboard/claude-code-rev / emitLoadError

Function emitLoadError

src/cli/print.ts:4846–4871  ·  view source on GitHub ↗

* Emits an error message in the correct format based on outputFormat. * When using stream-json, writes JSON to stdout; otherwise writes plain text to stderr.

(
  message: string,
  outputFormat: string | undefined,
)

Source from the content-addressed store, hash-verified

4844 * When using stream-json, writes JSON to stdout; otherwise writes plain text to stderr.
4845 */
4846function emitLoadError(
4847 message: string,
4848 outputFormat: string | undefined,
4849): void {
4850 if (outputFormat === 'stream-json') {
4851 const errorResult = {
4852 type: 'result',
4853 subtype: 'error_during_execution',
4854 duration_ms: 0,
4855 duration_api_ms: 0,
4856 is_error: true,
4857 num_turns: 0,
4858 stop_reason: null,
4859 session_id: getSessionId(),
4860 total_cost_usd: 0,
4861 usage: EMPTY_USAGE,
4862 modelUsage: {},
4863 permission_denials: [],
4864 uuid: randomUUID(),
4865 errors: [message],
4866 }
4867 process.stdout.write(jsonStringify(errorResult) + '\n')
4868 } else {
4869 process.stderr.write(message + '\n')
4870 }
4871}
4872
4873/**
4874 * Removes an interrupted user message and its synthetic assistant sentinel

Callers 1

loadInitialMessagesFunction · 0.85

Calls 3

getSessionIdFunction · 0.85
jsonStringifyFunction · 0.85
writeMethod · 0.45

Tested by

no test coverage detected