MCPcopy Create free account
hub / github.com/ehmicky/log-process-errors / handleEvent

Function handleEvent

src/events.js:13–31  ·  view source on GitHub ↗
(
  { event, opts: { onError, exit }, previousEvents },
  value,
  origin,
)

Source from the content-addressed store, hash-verified

11]
12
13export const handleEvent = async (
14 { event, opts: { onError, exit }, previousEvents },
15 value,
16 origin,
17) => {
18 const valueA = await resolveValue(value, event)
19
20 if (
21 isDoubleRejection(event, origin) ||
22 isLimited(valueA, event, previousEvents) ||
23 isRepeated(valueA, previousEvents)
24 ) {
25 return
26 }
27
28 const error = getError(valueA, event)
29 await onError(error, event)
30 exitProcess(exit, event)
31}
32
33// `rejectionHandled` pass a `Promise` as argument. The other events pass the
34// main value as is.

Callers

nothing calls this directly

Calls 6

isLimitedFunction · 0.90
isRepeatedFunction · 0.90
getErrorFunction · 0.90
exitProcessFunction · 0.90
resolveValueFunction · 0.85
isDoubleRejectionFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…