Closed andyli closed 5 years ago
https://github.com/haxetink/tink_await/pull/17
A few things here:
Promise<T> = Surprise<T, Error>
;tink.core.Error#data
, so the transformed code actually tries to access "failed".data
which gives you null (undefined)A quick fix looks like this:
using tink.CoreApi;
@await class Main {
static function test():Promise<String> {
return Surprise.async(function(resolve){
resolve(Failure(Error.withData('', 'failed')));
});
}
@async static function main() {
try {
var v = @await test();
trace("v: " + v);
} catch(err:Dynamic) {
trace("err: " + err);
}
}
}
Please try git head
Confirm it works as expected, thanks for the quick fix!
Tested with Haxe 3.4.7 and tink_await 0.4.0.
The program outputs
err: null
but I expect it to beerr: failed
.