(label: string, error?: unknown)
| 30 | import { getDebugSurface } from "./globals.js"; |
| 31 | |
| 32 | export function swallow(label: string, error?: unknown): void { |
| 33 | if (typeof window === "undefined") return; |
| 34 | const w = getDebugSurface(); |
| 35 | |
| 36 | const handler = w.__hf?.onSwallowed; |
| 37 | if (handler) { |
| 38 | try { |
| 39 | handler({ label, error }); |
| 40 | } catch (handlerError) { |
| 41 | // Don't recurse into swallow() — a consumer hook that throws |
| 42 | // shouldn't be allowed to take down the runtime, and routing the |
| 43 | // failure back through swallow() would loop. Drop on the floor; |
| 44 | // the original error already had its surface above. |
| 45 | void handlerError; |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | if (w.__hfDebug || w.__HYPERFRAMES_DEBUG) { |
| 50 | // eslint-disable-next-line no-console -- intentional debug surface |
| 51 | console.debug(`[hyperframes] ${label} swallowed:`, error); |
| 52 | } |
| 53 | } |
no test coverage detected