SubtitleEdit/subtitleedit · error · PlatformNotSupportedException

Unsupported operating system

Error message

Unsupported operating system

What it means

Thrown by OpenFileWithDefaultProgram when the OS is not Windows, macOS, or Linux. The method delegates to OS-specific openers (explorer/open/xdg-open) and has no opener for other systems, so it refuses with PlatformNotSupportedException before attempting a launch. This is the only path that reaches the final else branch.

Source

Thrown at src/ui/Logic/Media/FileHelper.cs:764

                    {
                        FileName = "open",
                        Arguments = $"\"{filePath}\"",
                        UseShellExecute = false
                    });
                }
                else if (OperatingSystem.IsLinux())
                {
                    // Linux: use 'xdg-open' command
                    Process.Start(new ProcessStartInfo
                    {
                        FileName = "xdg-open",
                        Arguments = $"\"{filePath}\"",
                        UseShellExecute = false
                    });
                }
                else
                {
                    throw new PlatformNotSupportedException("Unsupported operating system");
                }
            }
            catch (Exception ex) when (ex is not FileNotFoundException && ex is not ArgumentException)
            {
                throw new InvalidOperationException($"Failed to open file: {filePath}", ex);
            }
        }
    }
}

View on GitHub (pinned to 17a9f07487)

Solutions

  1. Run on Windows, macOS, or Linux where a default-program opener exists.
  2. Add a branch mapping to your platform's opener (e.g. FreeBSD may still have xdg-open installed).
  3. Catch PlatformNotSupportedException and show the user the path so they can open it manually.

Example fix

// before
else throw new PlatformNotSupportedException("Unsupported operating system");

// after: fall back to xdg-open for any remaining Unix, else tell the user
else if (OperatingSystem.IsFreeBSD())
    Process.Start(new ProcessStartInfo { FileName = "xdg-open", Arguments = $"\"{filePath}\"" });
else
    throw new PlatformNotSupportedException($"No default opener for {RuntimeInformation.OSDescription}");
Defensive patterns

Strategy: validation

Validate before calling

if (!OperatingSystem.IsWindows() && !OperatingSystem.IsMacOS() && !OperatingSystem.IsLinux())
{ /* no opener available; show the path instead */ }

Type guard

static bool HasDefaultOpener() =>
    OperatingSystem.IsWindows() || OperatingSystem.IsMacOS() || OperatingSystem.IsLinux();

Try / catch

try { FileHelper.OpenFileWithDefaultProgram(path); }
catch (PlatformNotSupportedException) { ClipboardSetText(path); showUser("Open manually: " + path); }

Prevention

When it happens

Trigger: Calling OpenFileWithDefaultProgram on FreeBSD, Solaris, or any OS where OperatingSystem.IsWindows/IsMacOS/IsLinux all return false.

Common situations: Running SE under .NET on a niche Unix variant with no xdg-open equivalent.

Related errors


AI-assisted analysis of SubtitleEdit/subtitleedit@17a9f07487 (2026-08-13). Data as JSON: /api/errors/df0b9dbf17c11836. Report an issue: GitHub.