Q:

Alternative to try, catch, finally in Haxe

In AS3 I could try/catch/finally a JSON file as follows:
try{
    myJSON = JSON.parse(_fileReference.data.toString());
}
catch (e:TypeError){ //String?
    _se.log.trace(e); //Never got called
}
finally{
    if (null == myJSON){
        _se.log.trace("SyntaxError: Error #1132: Invalid JSON parse input.");
        return;
    }
}

Is there a way to reproduce the Finally stage in Haxe? Finally was quite important to me, I liked the way it worked in this given scenario, it stopped the application from crashing or pausing with a window pop-up of the error.
Preferably looking for a raw solution that works for both AS3 and Haxe.

A:

There is the scopes haxelib which I believe provides similar functionality to try/catch/finally with scope guards and protected blocks. See: https://bitbucket.org/parensoft/scopes
From the primitive protected/cleanup expressions example in their readme:
import scopes.Protect;

Protect.protect(PROT, CLEAN);

CLEAN will always be executed when PROT exits. This includes normal
  completion or an abrupt exit with an exception, or a return, break or
  continue statement.
Any abrupt exit from the CLEAN expression will shadow the previous
  abrupt exit from the PROT expression, if any.
The value of the Protect.protect(PROT, CLEAN) expression is the value
  of the PROT expression if it completes; otherwise it's unspecified
  (and unreachable as well).

Actually adding the finally keyword to Haxe has been discussed before: https://github.com/HaxeFoundation/haxe/issues/3335 - however it looks like it is pending further discussion.

