[now-static-build] Update error message to mention project settings (#3926)

This PR improves the error message to make it actionable.

The docs will be updated in https://github.com/zeit/docs/pull/1661 with even more detail.
This commit is contained in:
Steven
2020-03-17 16:29:43 -04:00
committed by GitHub
parent 25fd1df35d
commit c1df8c8bd1
2 changed files with 25 additions and 10 deletions

View File

@@ -89,39 +89,54 @@ async function filePost (body, digest) {
'x-now-size': body.length,
};
const resp = await fetchWithAuth('/v2/now/files', {
const url = '/v2/now/files';
const resp = await fetchWithAuth(url, {
method: 'POST',
headers,
body,
});
const json = await resp.json();
if (json.error) {
console.log('headers', resp.headers);
throw new Error(json.error.message);
const { status, statusText, headers } = resp;
const { message } = json.error;
console.log('Fetch Error', { url , status, statusText, headers, digest });
throw new Error(message);
}
return json;
}
async function deploymentPost (payload) {
const resp = await fetchWithAuth('/v6/now/deployments?forceNew=1', {
const url = '/v6/now/deployments?forceNew=1';
const resp = await fetchWithAuth(url, {
method: 'POST',
body: JSON.stringify(payload),
});
console.log(`fetch status: ${resp.status} ${resp.statusText}`);
const json = await resp.json();
if (json.error) {
console.log('headers', resp.headers);
throw new Error(json.error.message);
const { status, statusText, headers } = resp;
const { message } = json.error;
console.log('Fetch Error', { url , status, statusText, headers });
throw new Error(message);
}
return json;
}
async function deploymentGet (deploymentId) {
const resp = await fetchWithAuth(`/v3/now/deployments/${deploymentId}`);
return await resp.json();
const url = `/v3/now/deployments/${deploymentId}`;
const resp = await fetchWithAuth(url);
const json = await resp.json();
if (json.error) {
const { status, statusText, headers } = resp;
const { message } = json.error;
console.log('Fetch Error', { url , status, statusText, headers });
throw new Error(message);
}
return json
}
let token;