{"record":{"id":"db42ab0ed0b3481a","repo":"rocksdanister/lively","slug":"i18n-getstring-textunsupportedfile-path-ge","errorCode":null,"errorMessage":"${i18n.GetString(\"TextUnsupportedFile\")} ({Path.GetExtension(filePath)})","messagePattern":"\\$\\{i18n\\.GetString\\(\"TextUnsupportedFile\"\\)\\} \\(\\{Path\\.GetExtension\\(filePath\\)\\}\\)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"warning","filePath":"src/Lively/Lively.UI.Shared/ViewModels/LibraryViewModel.cs","lineNumber":622,"sourceCode":"                }\n\n                var arguments = fileType.IsApplicationWallpaper() ? \n                    await dialogService.ShowTextInputDialogAsync(i18n.GetString(\"TextWallpaperCommandlineArgs\"), \"Examples: --myarguments1 -myargument2\") : \n                    string.Empty;\n\n                // Show and confirm project files.\n                if (fileType.IsDirectoryProject() && !await dialogService.ShowWallpaperProjectDirectoryDialogAsync(Path.GetDirectoryName(filePath)))\n                    return null;\n\n                var result = await desktopCore.CreateWallpaper(filePath, fileType, arguments);\n                var model = result != null ? AddWallpaper(result) : null;\n\n                if (autoSetWallpaper && model != null)\n                    await desktopCore.SetWallpaper(model, userSettings.Settings.SelectedDisplay);\n\n                return model;\n            }\n            throw new InvalidOperationException($\"{i18n.GetString(\"TextUnsupportedFile\")} ({Path.GetExtension(filePath)})\");\n        }\n\n        /// <summary>\n        /// Bulk import wallpapers; Only supports local media files and wallpaper package format.\n        /// </summary>\n        public async Task AddWallpapers(List<string> files, CancellationToken cancellationToken, IProgress<int> progress)\n        {\n            // Bulk import only supports wallpaper package and media files.\n            files.RemoveAll(x => !FileTypes.IsWallpaperPackageExtension(x) && !FileTypes.GetFileType(x).IsMediaWallpaper());\n            for (int i = 0; i < files.Count; i++)\n            {\n                try\n                {\n                    if (cancellationToken.IsCancellationRequested)\n                        break;\n\n                    var file = files[i];\n                    if (FileTypes.IsWallpaperPackageExtension(file))","sourceCodeStart":604,"sourceCodeEnd":640,"githubUrl":"https://github.com/rocksdanister/lively/blob/c1036feb664960722e34bf4309042c247d6a909d/src/Lively/Lively.UI.Shared/ViewModels/LibraryViewModel.cs#L604-L640","documentation":"Thrown at the tail of AddWallpaperFile when the file is neither a wallpaper package nor a recognised media type (FileTypes.GetFileType returns the -1 sentinel). The message is the localized 'unsupported file' string plus the actual extension for diagnostics.","triggerScenarios":"AddWallpaperFile(filePath, ...) where FileTypes.IsWallpaperPackageExtension is false AND FileTypes.GetFileType(filePath) is the (WallpaperType)(-1) sentinel — i.e. an extension Lively cannot handle.","commonSituations":"User drops a .pdf, .exe, .txt, or an unsupported media format; a new codec/extension not yet registered in FileTypes; case-sensitivity so .MP4 vs .mp4 mismatched the registry.","solutions":["Filter the file picker / drag-drop to supported extensions before calling AddWallpaperFile.","Register the new extension in FileTypes if support is intended.","Catch InvalidOperationException and show the localized message + extension to the user."],"exampleFix":"// before\nthrow new InvalidOperationException($\"{i18n.GetString(\"TextUnsupportedFile\")} ({Path.GetExtension(filePath)})\");\n\n// after — pre-filter and never reach the throw for known-unsupported types\nif (FileTypes.GetFileType(filePath) is (WallpaperType)(-1))\n{\n    await dialogService.ShowMessageAsync($\"{i18n.GetString(\"TextUnsupportedFile\")} ({Path.GetExtension(filePath)})\");\n    return null;\n}","handlingStrategy":"validation","validationCode":"if (!FileTypes.IsWallpaperPackageExtension(filePath)\n    && FileTypes.GetFileType(filePath) is (WallpaperType)(-1))\n{\n    await dialogService.ShowMessageAsync($\"{i18n.GetString(\"TextUnsupportedFile\")} ({Path.GetExtension(filePath)})\");\n    return;\n}","typeGuard":"static bool IsSupportedFile(string filePath)\n    => FileTypes.IsWallpaperPackageExtension(filePath)\n       || FileTypes.GetFileType(filePath) is not (WallpaperType)(-1);","tryCatchPattern":"try { await libraryViewModel.AddWallpaperFile(filePath, autoSetWallpaper); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(i18n.GetString(\"TextUnsupportedFile\")))\n{ /* already user-visible; optionally log */ }","preventionTips":["Constrain the file picker / drag-drop to supported extensions.","Register new extensions in FileTypes when adding format support.","Handle extension case-insensitively to avoid false unsupported errors."],"tags":["wallpaper","file-type","validation","i18n"],"backgroundTag":null,"analyzedSha":"c1036feb664960722e34bf4309042c247d6a909d","analyzedAt":"2026-08-13T13:03:12.648Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}