|
|
@ -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
|
|
|
|