MCPcopy
hub / github.com/codeaashu/claude-code / logError

Function logError

src/utils/log.ts:158–199  ·  view source on GitHub ↗
(error: unknown)

Source from the content-addressed store, hash-verified

156})
157
158export function logError(error: unknown): void {
159 const err = toError(error)
160 if (feature('HARD_FAIL') && isHardFailMode()) {
161 // biome-ignore lint/suspicious/noConsole:: intentional crash output
162 console.error('[HARD FAIL] logError called with:', err.stack || err.message)
163 // eslint-disable-next-line custom-rules/no-process-exit
164 process.exit(1)
165 }
166 try {
167 // Check if error reporting should be disabled
168 if (
169 // Cloud providers (Bedrock/Vertex/Foundry) always disable features
170 isEnvTruthy(process.env.CLAUDE_CODE_USE_BEDROCK) ||
171 isEnvTruthy(process.env.CLAUDE_CODE_USE_VERTEX) ||
172 isEnvTruthy(process.env.CLAUDE_CODE_USE_FOUNDRY) ||
173 process.env.DISABLE_ERROR_REPORTING ||
174 isEssentialTrafficOnly()
175 ) {
176 return
177 }
178
179 const errorStr = err.stack || err.message
180
181 const errorInfo = {
182 error: errorStr,
183 timestamp: new Date().toISOString(),
184 }
185
186 // Always add to in-memory log (no dependencies needed)
187 addToInMemoryErrorLog(errorInfo)
188
189 // If sink not attached, queue the event
190 if (errorLogSink === null) {
191 errorQueue.push({ type: 'error', error: err })
192 return
193 }
194
195 errorLogSink.logError(err)
196 } catch {
197 // pass
198 }
199}
200
201export function getInMemoryErrors(): { error: string; timestamp: string }[] {
202 return [...inMemoryErrorLog]

Callers 15

persistBinaryContentFunction · 0.70
platform.tsFile · 0.70
fileHistoryTrackEditFunction · 0.70
fileHistoryMakeSnapshotFunction · 0.70
fileHistoryRewindFunction · 0.70
fileHistoryGetDiffStatsFunction · 0.70
fileHistoryHasAnyChangesFunction · 0.70
applySnapshotFunction · 0.70
computeDiffStatsForFileFunction · 0.70
restoreBackupFunction · 0.70
copyFileHistoryForResumeFunction · 0.70
agenticSessionSearchFunction · 0.70

Calls 7

toErrorFunction · 0.85
featureFunction · 0.85
isEnvTruthyFunction · 0.85
isEssentialTrafficOnlyFunction · 0.85
addToInMemoryErrorLogFunction · 0.70
errorMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected