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

Function make

packages/effect/src/ErrorReporter.ts:126–162  ·  view source on GitHub ↗
(
  report: (options: {
    readonly cause: Cause.Cause<unknown>
    readonly error: Error
    readonly attributes: ReadonlyRecord<string, unknown>
    readonly severity: Severity
    readonly fiber: Fiber.Fiber<unknown, unknown>
    readonly timestamp: bigint
  }) => void
)

Source from the content-addressed store, hash-verified

124 * @since 4.0.0
125 */
126export const make = (
127 report: (options: {
128 readonly cause: Cause.Cause<unknown>
129 readonly error: Error
130 readonly attributes: ReadonlyRecord<string, unknown>
131 readonly severity: Severity
132 readonly fiber: Fiber.Fiber<unknown, unknown>
133 readonly timestamp: bigint
134 }) => void
135): ErrorReporter => {
136 const reported = new WeakSet<Cause.Cause<unknown> | object>()
137 return {
138 [TypeId]: TypeId,
139 report(options) {
140 if (reported.has(options.cause)) return
141 reported.add(options.cause)
142 for (let i = 0; i < options.cause.reasons.length; i++) {
143 const reason = options.cause.reasons[i]
144 if (reason._tag === "Interrupt") continue
145 const original = reason._tag === "Fail" ? reason.error : reason.defect
146 const isObject = typeof original === "object" && original !== null
147 if (isObject) {
148 if (reported.has(original)) continue
149 reported.add(original)
150 }
151 if (isIgnored(original)) continue
152 const pretty = effect.causePrettyError(original as any, reason.annotations)
153 report({
154 ...options,
155 error: pretty,
156 severity: isObject ? getSeverity(original) : "Info",
157 attributes: isObject ? getAttributes(original) : emptyAttributes
158 })
159 }
160 }
161 }
162}
163
164/**
165 * Context reference that holds the set of active error reporters for the

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected