-
Notifications
You must be signed in to change notification settings - Fork 35
Error Handling
Jing Lu edited this page May 10, 2013
·
34 revisions
Standard ECMAScript try/catch/finally/throw are supported by ReoScript.
try {
// call non-existed function should cause a run-time error
undefinedfunc();
} catch(e) {
// e is instance of Error function
alert(e.message);
}
allocMemory();
try {
// do something and error here
undefinedfunc();
} catch(e) {
console.log(e);
} finally {
releaseMemory();
}
try {
if (true) {
throw new Error('error anyway');
}
} catch(e) {
alert(e.message) // 'error anyway'
}
try {
try {
throw 'inner error';
} catch(e) {
if(e == 'inner error') {
throw 'outer error';
}
}
} catch(e) {
// e is 'outer error'
}