Skip to content

Commit

Permalink
Merge pull request #5209 from Shopify/jm/01-15-unify_asset_upload_err…
Browse files Browse the repository at this point in the history
…or_reporting

[Themes] `theme dev` - unify asset upload error reporting
  • Loading branch information
jamesmengo authored Jan 16, 2025
2 parents 92d7121 + 0971b54 commit 7d889bd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/stupid-phones-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/theme': minor
---

Unify how asset upload errors are reported in the `theme dev` command
10 changes: 4 additions & 6 deletions packages/theme/src/cli/utilities/theme-uploader.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -432,10 +432,8 @@ async function handleFailedUploads(
function reportFailedUploads(uploadResults: Map<string, Result>) {
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?.join('\n') ?? 'File upload failed'
renderThrownError(key, new Error(errorMessage))
}
}
}

0 comments on commit 7d889bd

Please sign in to comment.