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

Function logError

src/utils/log.ts:158–198  ·  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 console.error('[HARD FAIL] logError called with:', err.stack || err.message)
162 // eslint-disable-next-line custom-rules/no-process-exit
163 process.exit(1)
164 }
165 try {
166 // Check if error reporting should be disabled
167 if (
168 // Cloud providers (Bedrock/Vertex/Foundry) always disable features
169 isEnvTruthy(process.env.CLAUDE_CODE_USE_BEDROCK) ||
170 isEnvTruthy(process.env.CLAUDE_CODE_USE_VERTEX) ||
171 isEnvTruthy(process.env.CLAUDE_CODE_USE_FOUNDRY) ||
172 process.env.DISABLE_ERROR_REPORTING ||
173 isEssentialTrafficOnly()
174 ) {
175 return
176 }
177
178 const errorStr = shortErrorStack(err)
179
180 const errorInfo = {
181 error: errorStr,
182 timestamp: new Date().toISOString(),
183 }
184
185 // Always add to in-memory log (no dependencies needed)
186 addToInMemoryErrorLog(errorInfo)
187
188 // If sink not attached, queue the event
189 if (errorLogSink === null) {
190 errorQueue.push({ type: 'error', error: err })
191 return
192 }
193
194 errorLogSink.logError(err)
195 } catch {
196 // pass
197 }
198}
199
200export function getInMemoryErrors(): { error: string; timestamp: string }[] {
201 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
isEssentialTrafficOnlyFunction · 0.85
shortErrorStackFunction · 0.85
isEnvTruthyFunction · 0.70
addToInMemoryErrorLogFunction · 0.70
errorMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected