onError(action: (err: Error)=>void): KEventController
Register a custom error handler. Can be used to draw a custom error screen.
param
action- The function that runs when the program errors.
// Create custom error handler
onError((err) => {
drawRect({
width: width(),
height: height(),
pos: center(),
color: RED,
anchor: `center,
});
drawText({
text: err.message,
size: 48,
width: width()/2,
anchor: `center`,
align: `center`,
pos: center(),
color: BLACK
});
});
// cause common error
let pos = add([
pos()
]);
returns
The event controller.
since
v3000.0
group
Events