(self: Cause.Cause<E>, options?: {
readonly includeCauseInStack?: boolean | undefined
})
| 310 | |
| 311 | /** @internal */ |
| 312 | export 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 */ |
| 350 | export const causePrettyError = ( |
no test coverage detected