Subj : Javascript Catch Error
To : High Spirit
From : echicken
Date : Fri Dec 15 2017 11:39 am
Re: Javascript Catch Error
By: High Spirit to All on Fri Dec 15 2017 10:44:03
HS> Is there anyway to catch an error and prevent Synchronet from
HS> disconnecting when the error occurs?
Try to avoid situations where your script will throw an error. When you
can't do that, wrap any code likely to generate an error in a try...catch:
try {
throw 'this is an error';
} catch (err) {
log(err);
}
There are often better ways of doing things, though. When doing file I/O for
example, you can avoid most errors by checking whether a file exists, whether
it was opened successfully, etc. before trying to do stuff with it.