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 [ return [
key, key,
// add support for escaping the @ as \@ typeof val === 'string'
val.replace(/^\\@/, '@') // 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'); if (this._debug) console.timeEnd('> [debug] /now/create');
// no retry on 4xx // no retry on 4xx
if (200 !== res.status && (400 <= res.status && 500 > res.status)) { let body;
if (this._debug) { try {
console.log('> [debug] bailing on creating due to %s', res.status); body = await res.json();
} } catch (err) {
return bail(responseError(res)); throw new Error('Unexpected response');
} }
if (200 !== res.status) { if (429 === res.status) {
throw new Error('Deployment initialization failed'); 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 // we report about files whose sizes are too big

Loading…
Cancel
Save