Bluesky app fork with some witchin' additions 💫

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