From 9cf51e3a1b926fd17b6b6d115d351a89ea5b2fc4 Mon Sep 17 00:00:00 2001 From: James Meng Date: Wed, 15 Jan 2025 14:43:28 -0800 Subject: [PATCH] Unify how asset upload errors are rendered --- packages/theme/src/cli/utilities/theme-uploader.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/theme/src/cli/utilities/theme-uploader.ts b/packages/theme/src/cli/utilities/theme-uploader.ts index 1069696561f..a259f17dda2 100644 --- a/packages/theme/src/cli/utilities/theme-uploader.ts +++ b/packages/theme/src/cli/utilities/theme-uploader.ts @@ -1,12 +1,12 @@ import {partitionThemeFiles} from './theme-fs.js' import {rejectGeneratedStaticAssets} from './asset-checksum.js' import {renderTasksToStdErr} from './theme-ui.js' -import {createSyncingCatchError} from './errors.js' +import {createSyncingCatchError, renderThrownError} from './errors.js' import {AdminSession} from '@shopify/cli-kit/node/session' import {Result, Checksum, Theme, ThemeFileSystem} from '@shopify/cli-kit/node/themes/types' import {AssetParams, bulkUploadThemeAssets, deleteThemeAsset} from '@shopify/cli-kit/node/themes/api' import {Task} from '@shopify/cli-kit/node/ui' -import {outputDebug, outputInfo, outputNewline, outputWarn} from '@shopify/cli-kit/node/output' +import {outputDebug} from '@shopify/cli-kit/node/output' interface UploadOptions { nodelete?: boolean @@ -432,10 +432,8 @@ async function handleFailedUploads( function reportFailedUploads(uploadResults: Map) { for (const [key, result] of uploadResults.entries()) { if (!result.success) { - const errorMessage = result.errors?.asset?.map((err) => `-${err}`).join('\n') - outputWarn(`Failed to upload file ${key}:`) - outputInfo(`${errorMessage}`) - outputNewline() + const errorMessage = result.errors?.asset?.map((err) => `-${err}`).join('\n') ?? 'File upload failed' + renderThrownError(key, new Error(errorMessage)) } } }