ciscoheat / buddy

Your friendly BDD testing library for Haxe!
MIT License
96 stars 24 forks source link

Stack traces for exceptions #9

Closed jasononeil closed 10 years ago

jasononeil commented 10 years ago

I tried to do this:

try {
    #if utest
    Assert.results = new List<Assertation>();
    #end
    spec.run(done, status);
    if (!spec.async) done();
}
catch (e : Dynamic) {
    var stackTrace = CallStack.toString( CallStack.exceptionStack() );
    status(false, Std.string(e) + stackTrace);
}

But the async code swallows up the exception stack and I'm not familiar enough with promhx to know where to look next :)

jasononeil commented 10 years ago

The above code kind of works if you use -D PromhxExposeErrors (though is stil a fairly ugly solution... a way of passing the stack trace to the reporter would be better).

ciscoheat commented 10 years ago

I've been trying to catch async exceptions using promhx, but I cannot figure it out exactly, especially when it's thrown on another thread as in Neko... maybe we can enlist the help of @jdonaldson?

ciscoheat commented 10 years ago

This and #10 is fixed now in version 0.9.0, but for synchronous exceptions only. I left a note in the FAQ explaining why.

jasononeil commented 10 years ago

Great, thank you!

When dealing with exceptions in async code I find it easier to use Promise<Outcome<SuccessType,ErrorType>> or similar anyway - exceptions in async code are always going to be a bit ugly.