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

Function causePrettyErrors

packages/effect/src/internal/effect.ts:312–347  ·  view source on GitHub ↗
(self: Cause.Cause<E>, options?: {
  readonly includeCauseInStack?: boolean | undefined
})

Source from the content-addressed store, hash-verified

310
311/** @internal */
312export const causePrettyErrors = <E>(self: Cause.Cause<E>, options?: {
313 readonly includeCauseInStack?: boolean | undefined
314}): Array<Error> => {
315 const errors: Array<Error> = []
316 const interrupts: Array<Cause.Interrupt> = []
317 if (self.reasons.length === 0) return errors
318
319 const prevStackLimit = getStackTraceLimit()
320 setStackTraceLimit(1)
321
322 for (const failure of self.reasons) {
323 if (failure._tag === "Interrupt") {
324 interrupts.push(failure)
325 continue
326 }
327 errors.push(
328 causePrettyError(
329 failure._tag === "Die" ? failure.defect : failure.error as any,
330 failure.annotations,
331 options
332 )
333 )
334 }
335 if (errors.length === 0) {
336 const cause = new Error("The fiber was interrupted by:")
337 cause.name = "InterruptCause"
338 cause.stack = interruptCauseStack(cause, interrupts)
339 const error = new globalThis.Error("All fibers interrupted without error", { cause })
340 error.name = "InterruptError"
341 error.stack = `${error.name}: ${error.message}`
342 errors.push(causePrettyError(error, interrupts[0].annotations, options))
343 }
344
345 setStackTraceLimit(prevStackLimit)
346 return errors
347}
348
349/** @internal */
350export const causePrettyError = (

Callers 1

causePrettyFunction · 0.85

Calls 5

getStackTraceLimitFunction · 0.90
setStackTraceLimitFunction · 0.90
causePrettyErrorFunction · 0.85
interruptCauseStackFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected