MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / emitLoadError

Function emitLoadError

source code/cli/print.ts:4843–4868  ·  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

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