Skip to content
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

Log stacktrace when a task fails #591

Closed
jzaefferer opened this issue Dec 21, 2012 · 21 comments
Closed

Log stacktrace when a task fails #591

jzaefferer opened this issue Dec 21, 2012 · 21 comments

Comments

@jzaefferer
Copy link
Member

Grunt 0.4 is terrible about debugging tasks, since it only logs exception messages and throws away the stack. Adding --verbose --debug doesn't make a difference. Grunt should log the exception stacktrace by default, since an exception always is a fatal error, there's no point in hiding that behind options.

See also #578 and my comment there.

@jzaefferer
Copy link
Member Author

So --stack is a really stupid option, took me a while to figure out it exists. Can we get rid of that and make it the default?

@cowboy
Copy link
Member

cowboy commented Dec 31, 2012

Most grunt users aren't task authors, and they don't want or need to see stack traces. They just want pretty grunt errors.

I'd recommend that you alias grunt='grunt --stack', and then you'll always get stack traces.

I will add a note in the plugin authoring guide about this.

@cowboy cowboy closed this as completed Dec 31, 2012
@damassi
Copy link

damassi commented Apr 25, 2013

I really feel like there should be a configuration option on the GruntFile which enables developers to turn this on and off without having to resort to the cli. In our office we share Grunt packages across many developers and I feel like it would be unreasonable to ask them to alias the grunt cmd to get proper stack traces.

@shama
Copy link
Member

shama commented Apr 25, 2013

@damassi You could add grunt.option('stack', true); in your gruntfile.

@damassi
Copy link

damassi commented Apr 25, 2013

Awesome, that worked perfect. Thank you!

@kumavis
Copy link

kumavis commented Oct 28, 2013

+1 for making this option on by default

@cvrebert
Copy link

+1 for --debug, --verbose, or perhaps both together, implying --stack.

@vladikoff
Copy link
Member

@cvrebert tracking in #864

@paulmccallick
Copy link

+1 for turning this on by default.

@ain
Copy link

ain commented Sep 15, 2014

👍 for default stack.

@ralphtheninja
Copy link

+1 for default or remove it completely.

@j03m
Copy link

j03m commented Dec 11, 2014

+1 on default

@okor
Copy link

okor commented Jun 5, 2015

+1 This option by default.

If an author is writing a task for non-authors then it should be up to them to make the call to suppress errors or not.

@bobfields
Copy link

I can't think of any reason why this wouldn't be the default. No errors means no stack trace, even with it turned on, same as pretty. Errors give us a place to look, to fix the problem. Even those who are not task authors can report the error to the authors.

@kuroky360
Copy link

+1

@r-tanner-f
Copy link

-1 for on by default. I don't want a stack trace dumped for every legitimate error that a plugin throws at me. --stack is accessible enough, and grunt.option('stack', true); is portable enough if your dev team can't handle a CLI flag.

@SteveHarris
Copy link

-1 for on by default, but maybe offer info in the error display like (--stack for details)

@ccorcos
Copy link

ccorcos commented Nov 15, 2016

I'm confused about the contention here. I don't see any reason you'd want to hide the stack trace when you get an error and grunt exits with 1. Its completely worthless when that happens.

@fabianjogschies
Copy link

+1 for default

@joeytwiddle
Copy link

joeytwiddle commented Jan 23, 2018

If the developers don't want to make it a default, a middle ground solution could be to raise awareness of the --stack option:

// before
Warning: Test Error Use --force to continue.

// after
Warning: Test Error Use --force to continue or --stack for details.

Alternatively, enable the stack option when --verbose or --debug are used. (I tried both of those options, then grunt --help, before I started googling, which brought me here.)

@ArmorDarks
Copy link

ArmorDarks commented Mar 10, 2018

I think the issue is that some errors do not have any meaning without stacks. In such cases, it would be better for task author to enforce stacks output for some fatal errors.

I'd propose following addition:

// Last argument when set to `true` enforces output of the error with stack trace
grunt.log.error(new Error('Hey, too bad :('), true)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests