-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Alternate "slim" version of empower. #20
Comments
Let me explain a history behind the code.
I've implemented the same strategy, but some of old browsers (including PhantomJS) have strange behavior. When I rethrow Errors after attaching some props, the props disappear. try {
try {
...
} catch (e) {
e.foo = 'bar';
throw e;
}
} catch (e) {
assert(e.foo === 'bar'); // Error on old PhantomJS
} refactor(empower): always re-instantiate AssertionError on rethrow · power-assert-js/empower@997da24 However, I found that the attached props are remaining on current PhantomJS. It's a delightful discovery. Thanks! |
@twada - Check the unit tests for all it does. For use outside AVA, throwing non-errors is probably a bad idea. Could you maybe split most of the functionality into another module? |
Yeah I'm working on that ! |
Update: Now in a beta stage |
Close this issue since twada/empower-core is going on. |
@twada
Poking through the code, I think there is room for a "slim" version of empower.
If my understanding is correct, then the following:
Does not require a formatter at all. It just attaches the context and re-throws a copy.
In the "slim" version I am picturing, it would only take a patterns argument.
Also, instead of re-throwing an error (which messes with the existing stack trace needlessly). You could just use
serialize-error
attach the context, and throw.We would format and print the message on the main thread using
powerAssertContext
.Is what I am saying making sense?
The text was updated successfully, but these errors were encountered: