display backend-driven upload failure messages (#11329)
This commit is contained in:
@@ -388,7 +388,11 @@ export async function processVideo(
|
||||
telemetry.processingFailed(e)
|
||||
dispatch({
|
||||
type: 'to_error',
|
||||
error: getProcessingErrorMessage(status?.error, i18n),
|
||||
error: getProcessingErrorMessage(
|
||||
status?.failureCode,
|
||||
status?.error,
|
||||
i18n,
|
||||
),
|
||||
signal,
|
||||
})
|
||||
return // Exit async loop
|
||||
@@ -421,7 +425,40 @@ export async function processVideo(
|
||||
}
|
||||
}
|
||||
|
||||
function getProcessingErrorMessage(error: string | undefined, i18n: I18n) {
|
||||
function getProcessingErrorMessage(
|
||||
failureCode: string | undefined,
|
||||
error: string | undefined,
|
||||
i18n: I18n,
|
||||
) {
|
||||
const validationError = getValidationErrorMessage(error, i18n)
|
||||
if (failureCode === 'validation_failure') {
|
||||
return (
|
||||
validationError ?? i18n._(msg`The selected video could not be processed.`)
|
||||
)
|
||||
}
|
||||
// Support workers deployed before failureCode was added.
|
||||
if (!failureCode && validationError) {
|
||||
return validationError
|
||||
}
|
||||
|
||||
switch (failureCode) {
|
||||
case 'encoding_failure':
|
||||
return i18n._(msg`The selected video could not be encoded.`)
|
||||
case 'pds_upload_failure':
|
||||
return i18n._(
|
||||
msg`The video could not be uploaded to your PDS. Please try again.`,
|
||||
)
|
||||
case 'pds_upload_unsupported_blob_size':
|
||||
return i18n._(
|
||||
msg`Your PDS does not support videos this large. Please try again with a smaller file.`,
|
||||
)
|
||||
case 'generic_failure':
|
||||
default:
|
||||
return i18n._(msg`Video failed to process`)
|
||||
}
|
||||
}
|
||||
|
||||
function getValidationErrorMessage(error: string | undefined, i18n: I18n) {
|
||||
switch (error) {
|
||||
case 'video_too_long':
|
||||
return i18n._(msg`The selected video is too long.`)
|
||||
@@ -429,8 +466,10 @@ function getProcessingErrorMessage(error: string | undefined, i18n: I18n) {
|
||||
return i18n._(msg`The selected video has an unsupported aspect ratio.`)
|
||||
case 'unsupported_codec':
|
||||
return i18n._(msg`The selected video uses an unsupported format.`)
|
||||
default:
|
||||
return i18n._(msg`Video failed to process`)
|
||||
case 'encoded_video_too_large':
|
||||
return i18n._(
|
||||
msg`The processed video is too large. Please try again with a smaller file.`,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user