AutoDarkMode/Windows-Auto-Night-Mode · warning · SwitchThemeException

Theme switching is unsuccessful

Error message

Theme switching is unsuccessful: {result}

What it means

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.

Solutions

  1. Ensure the service is running and not mid-switch.
  2. Check the service log filtered by the cursors component.
  3. Retry the switch; transient OS cursor-file locks can cause a one-off failure.
  4. Verify cursor theme files referenced in config exist on disk.
Defensive patterns

Strategy: try-catch

Validate before calling

// Confirm cursor theme files exist before requesting a switch
public static bool CursorFilesExist(AdmConfigBuilder b) =>
    b.Config.CursorsSwitch.Component.Paths.All(File.Exists);

Try / catch

// Already caught locally. To surface the failure to callers, change
// 'async void RequestThemeSwitch()' to 'async Task RequestThemeSwitchAsync()'
// and await it so the caller can catch SwitchThemeException.

Prevention

When it happens

Trigger: CursorsViewModel.RequestThemeSwitch() fires after a cursor-related setting change. The service reply to Command.RequestSwitch (15s timeout) is not 'Ok'.

Common situations: Cursor theme switch component failed in the service; service busy/unreachable; 15s timeout exceeded; a dependent OS cursor API returned an error.

Related errors


AI-assisted analysis of AutoDarkMode/Windows-Auto-Night-Mode@c15b28e921 (2026-08-13). Data as JSON: /api/errors/6f42f973dc761c54. Report an issue: GitHub.

Appendix: source

Thrown at AutoDarkModeApp/ViewModels/CursorsViewModel.cs:131

            _builder.Save();
        }
        catch (Exception ex)
        {
            _errorService.ShowErrorMessage(ex, App.MainWindow.Content.XamlRoot, "CursorsPage");
        }
        RequestThemeSwitch();
    }



    private async void RequestThemeSwitch()
    {
        try
        {
            var result = await MessageHandler.Client.SendMessageAndGetReplyAsync(Command.RequestSwitch, 15);
            if (result != StatusCode.Ok)
            {
                throw new SwitchThemeException(result, "CursorsViewModel");
            }
        }
        catch (Exception ex)
        {
            await _errorService.ShowErrorMessage(ex, App.MainWindow.Content.XamlRoot, "CursorsViewModel");
        }
    }
}

View on GitHub (pinned to c15b28e921)