yo icon indicating copy to clipboard operation
yo copied to clipboard

Better npm error messages

Open eddiemonge opened this issue 9 years ago • 8 comments

Running this without a connection throws a not-user friendly error.

yo
-------------------------------------------------------------------------------------------------------------------
? 'Allo Eddie! What would you like to do? Install a generator
? Search npm for generators: angular

     _-----_
    |       |    .----------------------.
    |--(o)--|    |     Bye from us!     |
   `---------´   |      Chat soon.      |
    ( _´U`_ )    |                      |
    /___A___\    |      Yeoman team     |
     |  ~  |     |   http://yeoman.io   |
   __'.___.'__   '----------------------'
 ´   `  |° ´ Y `


NpmError: Failed to fetch npm registry (see http://status.npmjs.org for status)
Error: getaddrinfo ENOTFOUND
undefined
Error: getaddrinfo ENOTFOUND
undefined
    at new NewError (/Users/eddie/Sites/OSS/yeoman/yo/node_modules/custom-error/index.js:14:13)
    at npmError (/Users/eddie/Sites/OSS/yeoman/yo/lib/routes/install.js:35:10)
    at Request._callback (/Users/eddie/Sites/OSS/yeoman/yo/lib/routes/install.js:53:15)
    at self.callback (/Users/eddie/Sites/OSS/yeoman/yo/node_modules/request/request.js:373:22)
    at Request.emit (events.js:95:17)
    at Request.onRequestError (/Users/eddie/Sites/OSS/yeoman/yo/node_modules/request/request.js:971:8)
    at ClientRequest.emit (events.js:95:17)
    at CleartextStream.socketErrorListener (http.js:1552:9)
    at CleartextStream.emit (events.js:95:17)
    at Socket.onerror (tls.js:1456:17)

Maybe something like:

yo
-------------------------------------------------------------------------------------------------------------------
? 'Allo Eddie! What would you like to do? Install a generator
? Search npm for generators: angular

     _-----_
    |       |    .----------------------.
    |--(o)--|    |     Bye from us!     |
   `---------´   |      Chat soon.      |
    ( _´U`_ )    |                      |
    /___A___\    |      Yeoman team     |
     |  ~  |     |   http://yeoman.io   |
   __'.___.'__   '----------------------'
 ´   `  |° ´ Y `

Sorry, but there was an error with your last action.
See the yo-error.log for more details

yo-error.log

NpmError: Failed to fetch npm registry (see http://status.npmjs.org for status)
Error: getaddrinfo ENOTFOUND
undefined
Error: getaddrinfo ENOTFOUND
undefined
    at new NewError (/Users/eddie/Sites/OSS/yeoman/yo/node_modules/custom-error/index.js:14:13)
    at npmError (/Users/eddie/Sites/OSS/yeoman/yo/lib/routes/install.js:35:10)
    at Request._callback (/Users/eddie/Sites/OSS/yeoman/yo/lib/routes/install.js:53:15)
    at self.callback (/Users/eddie/Sites/OSS/yeoman/yo/node_modules/request/request.js:373:22)
    at Request.emit (events.js:95:17)
    at Request.onRequestError (/Users/eddie/Sites/OSS/yeoman/yo/node_modules/request/request.js:971:8)
    at ClientRequest.emit (events.js:95:17)
    at CleartextStream.socketErrorListener (http.js:1552:9)
    at CleartextStream.emit (events.js:95:17)
    at Socket.onerror (tls.js:1456:17)

eddiemonge avatar Jan 08 '15 20:01 eddiemonge

If we can tell what's been wrong and provide useful error message, I'm all for it.

But simply hiding away the error log is not useful IMO

SBoudrias avatar Jan 08 '15 21:01 SBoudrias

yeah i was debating having some of the detail but moving the stacktrace and more detailed information to a log.

eddiemonge avatar Jan 08 '15 22:01 eddiemonge

if by default yo would only display the error msg, an option/flag to get the full stacktrace in console would be nice/ required.

gaboesquivel avatar Jan 09 '15 15:01 gaboesquivel

Yeah, we can just show the stacktrace when --verbose is passed.

sindresorhus avatar Jan 09 '15 16:01 sindresorhus

Thing is... It's already hard to get a stacktrace when someone open an issue on our repos. If we hide the stack away, it'll be close to impossible to have details.

SBoudrias avatar Jan 09 '15 19:01 SBoudrias

+1, having to tell everyone to include the --verbose flag after opening an issue is going to be miserable.

kevva avatar Jan 09 '15 19:01 kevva

isnt that kind of a convention in other things though?'

side conversation, should we really be throwing an error on network issues? Shouldn't it just say, 'network problems, want to try something else?'

eddiemonge avatar Jan 09 '15 19:01 eddiemonge

Hmm, yeah, that's true...

At least we can handle it for Error: getaddrinfo ENOTFOUND and show a message instead as it means we can't connect. No need for stacktrace in that case.

sindresorhus avatar Jan 10 '15 05:01 sindresorhus