@reactgjs/react-gtk
Version:
## Getting Started
39 lines (38 loc) • 1.05 kB
JavaScript
// src/runtime/timers.ts
var EOL = "\n";
function handleTimerCbError(e, type, stack) {
const stackFmtd = stack ? __console_proxy.formatStackTrace(
__console_proxy.mapStackTrace(stack),
2
) : "Stack trace not available";
__console_proxy.error(
e,
`${EOL}${EOL}The above error occured in a callback provided to ${type} in here:${EOL}${stackFmtd}`
);
}
function runWithErrorHandler(cb, type, stack) {
try {
const res = cb();
if (res instanceof Promise) {
res.catch((e) => handleTimerCbError(e, type, stack));
}
} catch (e) {
handleTimerCbError(e, type, stack);
}
}
function __setTimeout_proxy(cb, time) {
const stack = new Error().stack?.split(EOL).slice(1).join(EOL);
setTimeout(() => {
runWithErrorHandler(cb, "setTimeout", stack);
}, time);
}
function __setInterval_proxy(cb, time) {
const stack = new Error().stack?.split(EOL).slice(1).join(EOL);
setInterval(() => {
runWithErrorHandler(cb, "setInterval", stack);
}, time);
}
export {
__setInterval_proxy,
__setTimeout_proxy
};