try catch or then catch code example
Example 1: try catch haxe
import haxe.Exception;
class Main {
static function main() {
try {
try {
doSomething();
} catch(e:Exception) {
trace(e.stack);
throw e; //rethrow
}
} catch(e:Exception) {
trace(e.stack);
}
}
static function doSomething() {
throw new Exception('Terrible error');
}
}
Example 2: try catch exception
First try block try to handle it
if not then catch block will handle it.
Finally block will executed regardless
of the outcome