scheduler error handling + style
This commit is contained in:
parent
45c7b29a96
commit
23e059a065
9 changed files with 444 additions and 425 deletions
|
|
@ -39,7 +39,7 @@ export class Cyclist {
|
|||
}
|
||||
});
|
||||
} catch (e) {
|
||||
console.warn('scheduler error: ', e.message);
|
||||
onLog(`error: ${e.message}`);
|
||||
onError?.(e);
|
||||
}
|
||||
}, // called slightly before each cycle
|
||||
|
|
|
|||
|
|
@ -15,18 +15,22 @@ export function repl({
|
|||
}) {
|
||||
const scheduler = new Cyclist({
|
||||
interval,
|
||||
onTrigger: (hap, deadline, duration) => {
|
||||
if (!hap.context.onTrigger) {
|
||||
return defaultOutput(hap, deadline, duration);
|
||||
onTrigger: async (hap, deadline, duration) => {
|
||||
try {
|
||||
if (!hap.context.onTrigger) {
|
||||
return await defaultOutput(hap, deadline, duration);
|
||||
}
|
||||
const cps = 1; // TODO: fix
|
||||
// call signature of output / onTrigger is different...
|
||||
return await hap.context.onTrigger(getTime() + deadline, hap, getTime(), cps);
|
||||
} catch (err) {
|
||||
onLog?.(`[cyclist] error: ${err.message}`, 'error');
|
||||
}
|
||||
const cps = 1; // TODO: fix
|
||||
// call signature of output / onTrigger is different...
|
||||
return hap.context.onTrigger(getTime() + deadline, hap, getTime(), cps);
|
||||
},
|
||||
onError: onSchedulerError,
|
||||
getTime,
|
||||
onToggle,
|
||||
onLog: (message) => onLog?.(`[clock] ${message}`),
|
||||
onLog: (message, type) => onLog?.(`[cyclist] ${message}`, type),
|
||||
});
|
||||
const evaluate = async (code, autostart = true) => {
|
||||
if (!code) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue