Browse Source

add messages for rate limit exceeded error

master
nkzawa 9 years ago
parent
commit
d0ef4ef7fc
  1. 8
      bin/now
  2. 8
      lib/index.js

8
bin/now

@ -137,6 +137,14 @@ async function sync (token) {
function handleError (err) {
if (403 === err.status) {
error('Authentication error. Run `now -L` or `now --login` to log-in again.');
} else if (429 === err.status) {
if (null != err.retryAfter) {
error('Rate limit exceeded error. Try again in ' +
ms(err.retryAfter * 1000, { long: true }) +
', or upgrade your account: https://zeit.co/now#pricing');
} else {
error('Rate limit exceeded error. Please try later.');
}
} else if (err.userError) {
error(err.message);
} else if (500 === err.status) {

8
lib/index.js

@ -195,5 +195,13 @@ function toRelative (path, base) {
function responseError (res) {
const err = new Error('Response error');
err.status = res.status;
if (429 === res.status) {
const retryAfter = res.headers.get('Retry-After');
if (retryAfter) {
err.retryAfter = parseInt(retryAfter, 10);
}
}
return err;
}

Loading…
Cancel
Save