diff --git a/packages/eas-cli/src/worker/upload.ts b/packages/eas-cli/src/worker/upload.ts index a139e4580e..25e0f93312 100644 --- a/packages/eas-cli/src/worker/upload.ts +++ b/packages/eas-cli/src/worker/upload.ts @@ -109,7 +109,8 @@ export async function uploadAsync(params: UploadParams): Promise { return retry(error); } - const defaultErrorMessage = `Upload of "${filePath}" failed: ${response.statusText}`; + const body = await response.json().catch(() => null); + const errorMessage = body?.error ?? `Upload of "${filePath}" failed: ${response.statusText}`; if ( response.status === 408 || @@ -117,17 +118,12 @@ export async function uploadAsync(params: UploadParams): Promise { response.status === 429 || (response.status >= 500 && response.status <= 599) ) { - const text = await response.text().catch(() => null); - return retry(new Error(text ? `${defaultErrorMessage}\n${text}` : defaultErrorMessage)); - } else if (response.status === 403) { - const body = await response.json(); - const message = body?.error ?? defaultErrorMessage; - throw new Error(message); + return retry(new Error(errorMessage)); } else if (response.status === 413) { const message = `Upload of "${filePath}" failed: File size exceeded the upload limit`; throw new Error(message); } else if (!response.ok) { - throw new Error(defaultErrorMessage); + throw new Error(errorMessage); } return {