SamVerschueren / dev-time-cli

Get the current local time of a GitHub user.
MIT License
179 stars 12 forks source link

Better message when exceeding rate limit #8

Closed hemanth closed 8 years ago

hemanth commented 8 years ago
$ dev-time SamVerschueren

SamVerschueren
HTTPError: Response code 403 (Forbidden)
    at /Users/Hemanth/.nvm/versions/node/v5.1.0/lib/node_modules/dev-time-cli/node_modules/got/index.js:102:11
    at BufferStream.<anonymous> (/Users/Hemanth/.nvm/versions/node/v5.1.0/lib/node_modules/dev-time-cli/node_modules/read-all-stream/index.js:64:3)
    at emitNone (events.js:72:20)
    at BufferStream.emit (events.js:166:7)
    at finishMaybe (/Users/Hemanth/.nvm/versions/node/v5.1.0/lib/node_modules/dev-time-cli/node_modules/readable-stream/lib/_stream_writable.js:509:14)
    at endWritable (/Users/Hemanth/.nvm/versions/node/v5.1.0/lib/node_modules/dev-time-cli/node_modules/readable-stream/lib/_stream_writable.js:519:3)
    at BufferStream.Writable.end (/Users/Hemanth/.nvm/versions/node/v5.1.0/lib/node_modules/dev-time-cli/node_modules/readable-stream/lib/_stream_writable.js:484:5)
    at Unzip.onend (_stream_readable.js:490:10)
    at Unzip.g (events.js:260:16)
    at emitNone (events.js:72:20)

This looks like I have exceeded the request limit, should we log something meaningful here? Say like use an auth-token?

SamVerschueren commented 8 years ago

Good point. But the error should be thrown in dev-time.

hemanth commented 8 years ago

Should the cli catch and throw a suitable message based on what kind of error it was, rather than dev-time doing it?

As in dev-time just throw the error and based on that the cli will log a suitable message.

SamVerschueren commented 8 years ago

Yes, the error Response code 403 doesn't say a lot. I think that GitHub returns the throttle limit in the headers so if the throttle limit is exceeded, it should throw new Error('throttle limit exceeded') instead of that 403. The message can then be formatted here.

hemanth commented 8 years ago

Either way, makes sense.

SamVerschueren commented 8 years ago

1.3.1

screen shot 2015-12-10 at 20 34 00

hemanth commented 8 years ago

:+1: