import '../errors/app_failure.dart'; import '../integrations/app_failure_adapter.dart'; import 'app_localizations.dart'; /// Presentation is the only layer that translates application failures. extension LocalizedAppMessages on AppLocalizations { String errorMessage(Object error) => failureMessage(appFailureFromError(error)); String failureMessage(AppFailure failure) => switch (failure.code) { AppErrorCode.operationFailed => operationFailed, AppErrorCode.agentRestartHint => agentRestartHint, AppErrorCode.loadRecentProjectsFailed => loadRecentProjectsFailed, AppErrorCode.loadProjectsFailed => loadProjectsFailed, AppErrorCode.projectAccessFailed => projectAccessFailed, AppErrorCode.projectLocationNotWritable => projectLocationNotWritable, AppErrorCode.projectLocationUnavailable => projectLocationUnavailable, AppErrorCode.projectLocationCreateFailed => projectLocationCreateFailed, AppErrorCode.projectMissingDirectory => projectMissingDirectory, AppErrorCode.recentProjectSaveFailed => recentProjectSaveFailed, AppErrorCode.lastProjectSaveFailed => lastProjectSaveFailed, AppErrorCode.enterProjectName => enterProjectName, AppErrorCode.projectSwitched => projectSwitched, AppErrorCode.notLocalMedia => notLocalMedia, AppErrorCode.revealMediaFailed => revealMediaFailed, AppErrorCode.openMatchingProject => openMatchingProject, AppErrorCode.openTimelineFailed => openTimelineFailed, AppErrorCode.projectMismatch => projectMismatch, AppErrorCode.projectAlreadyExists => projectAlreadyExists, AppErrorCode.openProjectFirst => openProjectFirst, AppErrorCode.localFilesOnly => localFilesOnly, AppErrorCode.foldersUnsupported => foldersUnsupported, AppErrorCode.mediaImportCancelled => mediaImportCancelled, AppErrorCode.fileAccessFailed => fileAccessFailed, AppErrorCode.registerMediaFailed => registerMediaFailed, AppErrorCode.mediaNoLongerExists => mediaNoLongerExists, AppErrorCode.mediaNoTracks => mediaNoTracks, AppErrorCode.invalidMediaDuration => invalidMediaDuration, AppErrorCode.mediaInfoUnsupported => mediaInfoUnsupported, AppErrorCode.mediaInfoFailed => mediaInfoFailed, AppErrorCode.saveTimelineFailed => saveTimelineFailed, AppErrorCode.projectNameInvalid => projectNameInvalid, AppErrorCode.projectLocationDefaultUnavailable => projectLocationDefaultUnavailable, AppErrorCode.chooseProjectLocation => chooseProjectLocation, AppErrorCode.timelineMissing => timelineMissing, AppErrorCode.timelineInUse => timelineInUse, AppErrorCode.timelineHasBackgroundTasks => timelineHasBackgroundTasks, AppErrorCode.timelineRequired => timelineRequired, AppErrorCode.projectSessionClosed => projectSessionClosed, AppErrorCode.timelineSessionClosed => timelineSessionClosed, AppErrorCode.mediaReadFailed => mediaReadFailed, AppErrorCode.mediaImportFailed => mediaImportFailed, AppErrorCode.unsupportedMediaType => unsupportedMediaType, AppErrorCode.mediaNoVideoTracks => mediaNoVideoTracks, AppErrorCode.mediaDurationOutOfRange => mediaDurationOutOfRange, AppErrorCode.resourceChecksumFailed => resourceChecksumFailed, AppErrorCode.enterName => enterName, AppErrorCode.agentLocationUnavailable => agentLocationUnavailable, AppErrorCode.agentLocationBusy => agentLocationBusy, AppErrorCode.startBackgroundRemovalFailed => startBackgroundRemovalFailed, AppErrorCode.subtitleEngineUnavailable => subtitleEngineUnavailable, AppErrorCode.timelineChanged => timelineChanged, AppErrorCode.resourceDownloadHttpFailed => resourceDownloadHttpFailed( failure.httpStatusCode?.toString() ?? '—', ), AppErrorCode.diagnostic => failure.diagnostic ?? operationFailed, }; }