MCPcopy Create free account
hub / github.com/Effect-TS/effect / cleanErrorStack

Function cleanErrorStack

packages/effect/src/internal/effect.ts:407–422  ·  view source on GitHub ↗
(
  stack: string,
  error: Error,
  annotations: ReadonlyMap<string, unknown> | undefined
)

Source from the content-addressed store, hash-verified

405const locationRegExp = /\((.*)\)/g
406
407const cleanErrorStack = (
408 stack: string,
409 error: Error,
410 annotations: ReadonlyMap<string, unknown> | undefined
411): string => {
412 const message = `${error.name}: ${error.message}`
413 const lines = (stack.startsWith(message) ? stack.slice(message.length) : stack).split("\n")
414 const out: Array<string> = [message]
415 for (let i = 1; i < lines.length; i++) {
416 if (/(?:Generator\.next|~effect\/Effect)/.test(lines[i])) {
417 break
418 }
419 out.push(lines[i])
420 }
421 return annotations ? addStackAnnotations(out.join("\n"), annotations) : out.join("\n")
422}
423
424const addStackAnnotations = (stack: string, annotations: ReadonlyMap<string, unknown>) => {
425 const frame = annotations?.get(CauseStackTrace.key) as StackFrame | undefined

Callers 1

causePrettyErrorFunction · 0.85

Calls 4

addStackAnnotationsFunction · 0.85
pushMethod · 0.80
joinMethod · 0.80
splitMethod · 0.45

Tested by

no test coverage detected