PJS Oh Noes Detection
Is there a way to detect when Oh Noes pops up? I'm asking, so that I may use `println` to paste save data in the event of a program crash, in order to allow users to retain save data even if something goes wrong
Sort of. You can detect when an error occurs using a try/catch statement. For example:
draw = function() {
try {
doStuff();
} catch (err) {
println("An error has occured: " + err);
println(saveData);
}
};
What does it define as an error? Is it simply when Oh-Noes would pop up, or is it more complicated than that?
It defines as an error whenever an error is thrown. Not every time oh noes pops up is an error for example oh noes will pop up when you are missing a semicolon even though your Javascript is perfectly fine.
Normally you can throw errors yourself using `throw new Error()` although this won't work in KA's PJS environment because of how scuffed it is.
Please sign in to leave a comment.