Be more descriptive with video errors, log less (#9886)
This commit is contained in:
@@ -54,6 +54,7 @@ const NETWORK_ERRORS = [
|
|||||||
'Failed to fetch',
|
'Failed to fetch',
|
||||||
'Load failed',
|
'Load failed',
|
||||||
'Upstream service unreachable',
|
'Upstream service unreachable',
|
||||||
|
'NetworkError when attempting to fetch resource',
|
||||||
]
|
]
|
||||||
|
|
||||||
export function isNetworkError(e: unknown) {
|
export function isNetworkError(e: unknown) {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
import {type CompressedVideo} from '#/lib/media/video/types'
|
import {type CompressedVideo} from '#/lib/media/video/types'
|
||||||
import {uploadVideo} from '#/lib/media/video/upload'
|
import {uploadVideo} from '#/lib/media/video/upload'
|
||||||
import {createVideoAgent} from '#/lib/media/video/util'
|
import {createVideoAgent} from '#/lib/media/video/util'
|
||||||
|
import {isNetworkError} from '#/lib/strings/errors'
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
|
|
||||||
type CaptionsTrack = {lang: string; file: File}
|
type CaptionsTrack = {lang: string; file: File}
|
||||||
@@ -403,7 +404,6 @@ function getUploadErrorMessage(e: unknown, _: I18n['_']): string | null {
|
|||||||
if (e instanceof AbortError) {
|
if (e instanceof AbortError) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
logger.error('Error uploading video', {safeMessage: e})
|
|
||||||
if (e instanceof ServerError || e instanceof UploadLimitError) {
|
if (e instanceof ServerError || e instanceof UploadLimitError) {
|
||||||
// https://github.com/bluesky-social/tango/blob/lumi/lumi/worker/permissions.go#L77
|
// https://github.com/bluesky-social/tango/blob/lumi/lumi/worker/permissions.go#L77
|
||||||
switch (e.message) {
|
switch (e.message) {
|
||||||
@@ -433,9 +433,20 @@ function getUploadErrorMessage(e: unknown, _: I18n['_']): string | null {
|
|||||||
return _(
|
return _(
|
||||||
msg`The selected video is larger than 100 MB. Please try again with a smaller file.`,
|
msg`The selected video is larger than 100 MB. Please try again with a smaller file.`,
|
||||||
)
|
)
|
||||||
default:
|
case 'Confirm your email address to upload videos':
|
||||||
return e.message
|
return _(msg`Please confirm your email address to upload videos.`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return _(msg`An error occurred while uploading the video.`)
|
|
||||||
|
if (isNetworkError(e)) {
|
||||||
|
return _(
|
||||||
|
msg`An error occurred while uploading the video. Please check your internet connection and try again.`,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
// only log errors if they are unknown (and not network errors)
|
||||||
|
logger.error('Error uploading video', {safeMessage: e})
|
||||||
|
}
|
||||||
|
|
||||||
|
const message = e instanceof Error ? e.message : ''
|
||||||
|
return _(msg`An error occurred while uploading the video. ${message}`)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user