yo
yo copied to clipboard
Better npm error messages
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)
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
yeah i was debating having some of the detail but moving the stacktrace and more detailed information to a log.
if by default yo would only display the error msg, an option/flag to get the full stacktrace in console would be nice/ required.
Yeah, we can just show the stacktrace when --verbose
is passed.
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.
+1, having to tell everyone to include the --verbose
flag after opening an issue is going to be miserable.
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?'
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.