[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

@@ -60,7 +60,7 @@ function validateDistDir(distDir: string) {
if (!exists()) { if (!exists()) {
throw new NowBuildError({ throw new NowBuildError({
code: 'NOW_STATIC_BUILD_NO_OUT_DIR', code: 'NOW_STATIC_BUILD_NO_OUT_DIR',
message: `No Output Directory named "${distDirName}" found after the Build completed.`, message: `No Output Directory named "${distDirName}" found after the Build completed. You can configure the Output Directory in your project settings.`,
link, link,
}); });
} }

View File

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