Browse Source

Merge pull request #128 from zeit/add/env-option

Better create error messages
master
Naoyuki Kanezawa 9 years ago
committed by GitHub
parent
commit
fc4a936ce2
  1. 6
      bin/now-deploy
  2. 22
      lib/index.js

6
bin/now-deploy

@ -301,8 +301,10 @@ async function sync (token) {
return [
key,
// add support for escaping the @ as \@
val.replace(/^\\@/, '@')
typeof val === 'string'
// add support for escaping the @ as \@
? val.replace(/^\\@/, '@')
: val
];
}));

22
lib/index.js

@ -203,18 +203,24 @@ export default class Now extends EventEmitter {
if (this._debug) console.timeEnd('> [debug] /now/create');
// no retry on 4xx
if (200 !== res.status && (400 <= res.status && 500 > res.status)) {
if (this._debug) {
console.log('> [debug] bailing on creating due to %s', res.status);
}
return bail(responseError(res));
let body;
try {
body = await res.json();
} catch (err) {
throw new Error('Unexpected response');
}
if (200 !== res.status) {
throw new Error('Deployment initialization failed');
if (429 === res.status) {
return bail(responseError(res));
} else if (res.status >= 400 && res.status < 500) {
const err = new Error(body.error.message);
err.userError = true;
return bail(err);
} else if (200 !== res.status) {
throw new Error(body.error.message);
}
return res.json();
return body;
});
// we report about files whose sizes are too big

Loading…
Cancel
Save