MCPcopy Create free account
hub / github.com/effect-app/libs / reportError

Function reportError

packages/infra/src/errorReporter.ts:18–53  ·  view source on GitHub ↗
(name: string)

Source from the content-addressed store, hash-verified

16}
17
18export function reportError(name: string) {
19 return Effect.fnUntraced(
20 function*(
21 cause: Cause.Cause<unknown>,
22 extras?: Record<string, unknown>,
23 level: LogLevel.Severity = "Error"
24 ) {
25 if (Cause.hasInterruptsOnly(cause)) {
26 yield* InfraLogger.logDebug("Interrupted").pipe(Effect.annotateLogs("extras", JSON.stringify(extras ?? {})))
27 return
28 }
29 const error = tryCauseException(cause, name)
30
31 yield* reportSentry(error, extras, LogLevelToSentry(level))
32 yield* InfraLogger
33 .logWithLevel(level, "Reporting error", cause)
34 .pipe(
35 Effect.annotateLogs(dropUndefined({
36 extras,
37 error: tryToReport(error),
38 cause: tryToJson(cause),
39 __error_name__: name
40 })),
41 Effect.catchCause((cause) => InfraLogger.logWarning("Failed to log error", cause)),
42 Effect.catchCause(() => InfraLogger.logFatal("Failed to log error cause"))
43 )
44
45 return error
46 },
47 (effect) =>
48 Effect.tapCause(effect, (cause) =>
49 InfraLogger.logError("Failed to report error", cause).pipe(
50 Effect.tapCause(() => InfraLogger.logFatal("Failed to log error cause"))
51 ))
52 )
53}
54
55function reportSentry(
56 error: CauseException<unknown>,

Callers 4

tapErrorCauseFunction · 0.90
errors.tsFile · 0.90
makeSSEFunction · 0.90
middleware.tsFile · 0.90

Calls 7

LogLevelToSentryFunction · 0.90
dropUndefinedFunction · 0.90
tryToReportFunction · 0.90
tryToJsonFunction · 0.90
tryCauseExceptionFunction · 0.70
reportSentryFunction · 0.70
pipeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…