{"record":{"id":"6f42f973dc761c54","repo":"AutoDarkMode/Windows-Auto-Night-Mode","slug":"theme-switching-is-unsuccessful-result-6f42f9","errorCode":null,"errorMessage":"Theme switching is unsuccessful: {result}","messagePattern":"Theme switching is unsuccessful: (.+?)","errorType":"exception","errorClass":"SwitchThemeException","httpStatus":null,"severity":"warning","filePath":"AutoDarkModeApp/ViewModels/CursorsViewModel.cs","lineNumber":131,"sourceCode":"            _builder.Save();\n        }\n        catch (Exception ex)\n        {\n            _errorService.ShowErrorMessage(ex, App.MainWindow.Content.XamlRoot, \"CursorsPage\");\n        }\n        RequestThemeSwitch();\n    }\n\n\n\n    private async void RequestThemeSwitch()\n    {\n        try\n        {\n            var result = await MessageHandler.Client.SendMessageAndGetReplyAsync(Command.RequestSwitch, 15);\n            if (result != StatusCode.Ok)\n            {\n                throw new SwitchThemeException(result, \"CursorsViewModel\");\n            }\n        }\n        catch (Exception ex)\n        {\n            await _errorService.ShowErrorMessage(ex, App.MainWindow.Content.XamlRoot, \"CursorsViewModel\");\n        }\n    }\n}","sourceCodeStart":113,"sourceCodeEnd":139,"githubUrl":"https://github.com/AutoDarkMode/Windows-Auto-Night-Mode/blob/c15b28e92138a1baff6165bbca80842f06cb819f/AutoDarkModeApp/ViewModels/CursorsViewModel.cs#L113-L139","documentation":"Identical pattern to error 7 but in CursorsViewModel.RequestThemeSwitch. Thrown when the RequestSwitch reply != Ok. SwitchThemeException carries Source='CursorsViewModel'. The async-void method catches it and routes to ShowErrorMessage. The only difference from other view models is the Source tag used for diagnostics.","triggerScenarios":"CursorsViewModel.RequestThemeSwitch() fires after a cursor-related setting change. The service reply to Command.RequestSwitch (15s timeout) is not 'Ok'.","commonSituations":"Cursor theme switch component failed in the service; service busy/unreachable; 15s timeout exceeded; a dependent OS cursor API returned an error.","solutions":["Ensure the service is running and not mid-switch.","Check the service log filtered by the cursors component.","Retry the switch; transient OS cursor-file locks can cause a one-off failure.","Verify cursor theme files referenced in config exist on disk."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Confirm cursor theme files exist before requesting a switch\npublic static bool CursorFilesExist(AdmConfigBuilder b) =>\n    b.Config.CursorsSwitch.Component.Paths.All(File.Exists);","typeGuard":null,"tryCatchPattern":"// Already caught locally. To surface the failure to callers, change\n// 'async void RequestThemeSwitch()' to 'async Task RequestThemeSwitchAsync()'\n// and await it so the caller can catch SwitchThemeException.","preventionTips":["Validate configured cursor file paths exist before switching.","Ensure no other tool is applying cursor themes simultaneously.","Debounce repeated switch requests from rapid UI changes.","Check the service log filtered by the cursors component on failure."],"tags":["theme-switch","ipc","named-pipe","cursors"],"backgroundTag":null,"analyzedSha":"c15b28e92138a1baff6165bbca80842f06cb819f","analyzedAt":"2026-08-13T21:04:56.049Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}