Browse Source

index: drastically improve error handling / messages for `create`

master
Guillermo Rauch 9 years ago
parent
commit
b83dbfb6ae
  1. 22
      lib/index.js

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