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

Bad example code in grunt.log docs? #28

Closed
russelldavis opened this issue Dec 18, 2013 · 1 comment
Closed

Bad example code in grunt.log docs? #28

russelldavis opened this issue Dec 18, 2013 · 1 comment

Comments

@russelldavis
Copy link

The docs for grunt.log have this example at the bottom of the page:

grunt.registerTask('something', 'Do something interesting.', function(arg) {
  var msg = 'Doing something...';
  grunt.verbose.write(msg);
  try {
    doSomethingThatThrowsAnExceptionOnError(arg);
    // Success!
    grunt.verbose.ok();
  } catch(e) {
    // Something went wrong.
    grunt.verbose.or.write(msg).error().error(e.message);
    grunt.fail.warn('Something went wrong.');
  }
});

The line grunt.verbose.or.write(msg).error().error(e.message); seems wrong to me. Wouldn't you want the calls to error to be logged regardless of the verbose setting? As is, the errors will not be logged in verbose mode, which doesn't seem right. Or am I misunderstanding something?

@shama
Copy link
Member

shama commented Dec 19, 2013

I think it's just an example showing how the API could be used rather than a likely situation. Although I'm always surprised with user preference of logging. Someone having a function named doSomethingThatThrowsAnExceptionOnError() is unlikely too. :)

We're always happy to take pull requests improving the docs if you have a better example that showcases the API though. Thanks!

@shama shama closed this as completed Dec 19, 2013
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

2 participants