Bluesky app fork with some witchin' additions 💫 witchsky.app
bluesky fork client

Be more descriptive with video errors, log less (#9886)

authored by samuel.fm and committed by

GitHub a6ba0810 49253dbd

+16 -4
+1
src/lib/strings/errors.ts
··· 54 54 'Failed to fetch', 55 55 'Load failed', 56 56 'Upstream service unreachable', 57 + 'NetworkError when attempting to fetch resource', 57 58 ] 58 59 59 60 export function isNetworkError(e: unknown) {
+15 -4
src/view/com/composer/state/video.ts
··· 13 13 import {type CompressedVideo} from '#/lib/media/video/types' 14 14 import {uploadVideo} from '#/lib/media/video/upload' 15 15 import {createVideoAgent} from '#/lib/media/video/util' 16 + import {isNetworkError} from '#/lib/strings/errors' 16 17 import {logger} from '#/logger' 17 18 18 19 type CaptionsTrack = {lang: string; file: File} ··· 403 404 if (e instanceof AbortError) { 404 405 return null 405 406 } 406 - logger.error('Error uploading video', {safeMessage: e}) 407 407 if (e instanceof ServerError || e instanceof UploadLimitError) { 408 408 // https://github.com/bluesky-social/tango/blob/lumi/lumi/worker/permissions.go#L77 409 409 switch (e.message) { ··· 433 433 return _( 434 434 msg`The selected video is larger than 100 MB. Please try again with a smaller file.`, 435 435 ) 436 - default: 437 - return e.message 436 + case 'Confirm your email address to upload videos': 437 + return _(msg`Please confirm your email address to upload videos.`) 438 438 } 439 439 } 440 - return _(msg`An error occurred while uploading the video.`) 440 + 441 + if (isNetworkError(e)) { 442 + return _( 443 + msg`An error occurred while uploading the video. Please check your internet connection and try again.`, 444 + ) 445 + } else { 446 + // only log errors if they are unknown (and not network errors) 447 + logger.error('Error uploading video', {safeMessage: e}) 448 + } 449 + 450 + const message = e instanceof Error ? e.message : '' 451 + return _(msg`An error occurred while uploading the video. ${message}`) 441 452 }