-
Notifications
You must be signed in to change notification settings - Fork 63
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
Only warn about init function being unset when it actually isn't set #151
Only warn about init function being unset when it actually isn't set #151
Conversation
It is definitely an improvement! Printing a stacktrace would be great, too. If you can't make the approach you tried in #102 to work, let's have
|
I'm wondering whether to change the message though. If The simplest change I can think of is Aside from that, here's the behaviour I've pushed for the default exception handling: Testing budb.cljs.register-test
ERROR: Exception outside tests:
#object[TypeError TypeError: undefined is not an object (evaluating '"foo".js.Error')]
ERROR: Stacktrace:
file:///Users/matthewdarling/code/budb/out/budb/cljs/register_test.js:9:18
cljs$test$run_block@file:///Users/matthewdarling/code/budb/out/cljs/test.js:378:17
file:///Users/matthewdarling/code/budb/out/running/doo_runner.js:1214:32
doo$runner$run_BANG_@file:///Users/matthewdarling/code/budb/out/doo/runner.js:60:50
global code
evaluateJavaScript@[native code]
evaluate@phantomjs://platform/webpage.js:390:39
phantomjs://code/phantom1145161256762945379.js:124:19
_onPageOpenFinished@phantomjs://platform/webpage.js:286:27 It seems like this code isn't hit when there's an exception inside a |
The messaging for those exceptions is more accurate than the original one. While it is rare to get exceptions outside of |
Tested a few things on my Mac running Sierra:
Makes sense that if Firefox had no stacktrace, Slimer wouldn't either. And the rest are all WebKit based so I guess that makes sense too. I didn't try Node or Nashorn, since they seemed to need a bit more setup. And can't test IE. Now that I've seen it firsthand, I think this looks silly:
Maybe it would be better to move all the printing for the stacktrace inside the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added my suggestions for the messages as review comments. After those changes, I'd be happy to merge this.
What do you mean with "Warns about exit function" in your table?
library/src/doo/runner.cljs
Outdated
(println e) | ||
(exit! false)))) | ||
(if-not (fn? *main-cli-fn*) | ||
(do (println "WARNING: doo's init function was not set") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest "doo's init function was not set or is not a function"
library/src/doo/runner.cljs
Outdated
(println | ||
(if (.hasOwnProperty e "stack") | ||
(.-stack e) | ||
"No stacktrace available.")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that in case there's no stacktrace, you should either see No stacktrace available
or nothing at all, but not ERROR: Stacktrace:
. I.e. please move the printing inside the if block, as you said.
"Warns about exit function" means the behaviour from this line. The Karma runners I tried all produce that warning. Looks like this: LOG: 'WARNING: doo's exit function was not properly set'
LOG: '#object[TypeError TypeError: doo.runner._STAR_exit_fn_STAR_ is null]' Possibly might need to have a setting for the Anyway, here's how things look within Karma (running on Firefox, so no stacktrace): LOG: 'Testing budb.cljs.register-test'
LOG: ''
LOG: 'ERROR: Exception outside tests:'
LOG: 'ERROR: #object[TypeError TypeError: "wololo".js is undefined]'
LOG: ''
LOG: 'No stacktrace available.' And within PhantomJS: Testing budb.cljs.register-test
ERROR: Exception outside tests:
ERROR: #object[TypeError TypeError: undefined is not an object (evaluating '"wololo".js.Error')]
ERROR: Stacktrace:
ERROR: file:///Users/matthewdarling/code/budb/out/budb/cljs/register_test.js:9:18
cljs$test$run_block@file:///Users/matthewdarling/code/budb/out/cljs/test.js:378:17
file:///Users/matthewdarling/code/budb/out/running/doo_runner.js:1214:32
doo$runner$run_BANG_@file:///Users/matthewdarling/code/budb/out/doo/runner.js:60:50
global code
evaluateJavaScript@[native code]
evaluate@phantomjs://platform/webpage.js:390:39
phantomjs://code/phantom6072078159243578225.js:124:19
_onPageOpenFinished@phantomjs://platform/webpage.js:286:27 At this point, the formatting seems okay. I took a small detour to check out whether |
Right, now I get what you mean by exit function. I'm going to merge this pull request now -- it's a good improvement as it is -- but if you want to do something to the exit function, don't hesitate to open a new PR. 😃 Thanks for making this better! |
Great work! I'm very happy that this made it in. |
Discussion started in #122.
I think this is what the original code was trying to do: if
*main-cli-fn*
wasnil
, then you'd get an error trying to usenil
as a function, catch that error, and report it. But there are many other reasons an exception might be thrown. A spurious warning will only distract people when they're trying to identify the real issue.Are there other kinds of invalid values for
*main-cli-fn*
? If so, those should be checked as well as fornil
.