rails / thor

Thor is a toolkit for building powerful command-line interfaces.
http://whatisthor.com/
MIT License
5.12k stars 553 forks source link

errors when loading Thorfiles do not include stacktrace #36

Closed technicalpickles closed 14 years ago

technicalpickles commented 14 years ago

Whenever errors/exceptions are encountered, only the error's type and message are displayed, excluding any sort of line information. For example, I had an uninitialized constant because I forgot to do a require, and I get this message:

WARNING: unable to load thorfile "/Users/technicalpickles/code/active/bedazzle/Thorfile": uninitialized constant Bedazzle::Build

I probably figure out this one just by looking at the code in Thorfile, but sometimes the error originates from code outside the code, and then it's basically impossible to debug.

It's a pretty easy fix to change thor to raise the error instead of putsing it. But the question remains, would this be acceptable for thor to do?

technicalpickles commented 14 years ago

Fixed in in my fork at technicalpickles@f85c87b7599474e649ad4638ea7a6663c5dfb126. I ended up just doing a puts of the error's backtrace.

eventualbuddha commented 14 years ago

I think it's probably acceptable, but I'm hesitant to change it. If I were fixing it myself I'd probably either show the top line of the stack trace or print the whole thing out to a log file.

technicalpickles commented 14 years ago

The top line of the backtrace wouldn't be sufficient in a lot of cases, I think. It's only useful if the error comes from a line in the Thorfile.

Logging it would be better, but I think it's a little overkill. If you're working on a thorfile in the current directory, and you are trying to call tasks defined in it, I really want to see backtraces that happened, and not have to know that there's an error log somewhere, and then actually open the file.

eventualbuddha commented 14 years ago

Fwiw, I believe this was added to prevent misbehaving global Thor helpers from always bombing Thor out. Do you guys have any thoughts on making that case usable/not horrible?

josevalim commented 14 years ago

Yeah, it was added to prevent thor from exploding due to some bad files. Showing the whole backtrace would be cumbersome, +1 for showing just the first line. You can invoke thor path/to/faulty/Thorfile --debug to get the whole error (at least I hope so).

eventualbuddha commented 14 years ago

I did what josevalim suggested. Find the commit here.