QL-Win/QuickLook · error · NotSupportedException
Unsupported file type: {ext}
Error message
Unsupported file type: {ext} What it means
Thrown in WebHandler.TryPrepare as the default arm of the extension switch selecting an IWebMetaProvider. The supported extensions are svg, svga, lottie/json, tgs, gv/dot, pu/puml/plantuml/wsd/iuml, drawio/dio, excalidraw. In practice this arm is defensive: TryPrepare is only entered after an outer `if` that checks the same extension set, so the throw is effectively unreachable unless the two lists diverge or the method is called directly with an unguarded extension.
Source
Thrown at QuickLook.Plugin/QuickLook.Plugin.ImageViewer/Webview/WebHandler.cs:85
{
if (!SettingHelper.Get("RenderSvgWeb", true, "QuickLook.Plugin.ImageViewer"))
{
metaWeb = null;
return false;
}
}
metaWeb = ext switch
{
".svg" => new SvgMetaProvider(path),
".svga" => new SvgaMetaProvider(path),
".lottie" or ".json" => new LottieMetaProvider(path),
".tgs" => new TgsMetaProvider(path),
".gv" or ".dot" => new GvMetaProvider(),
".pu" or ".puml" or ".plantuml" or ".wsd" or ".iuml" => new PuMetaProvider(),
".drawio" or ".dio" => new DrawioMetaProvider(),
".excalidraw" => new ExcalidrawMetaProvider(),
_ => throw new NotSupportedException($"Unsupported file type: {ext}")
};
var sizeSvg = metaWeb.GetSize();
if (!sizeSvg.IsEmpty)
context.SetPreferredSizeFit(sizeSvg, 0.8d);
else
context.PreferredSize = new Size(800, 600);
context.Theme = (Themes)SettingHelper.Get("LastTheme", 1, "QuickLook.Plugin.ImageViewer");
return true;
}
metaWeb = null;
return false;
}
public static bool TryView(string path, ContextObject context, IWebMetaProvider metaWeb, out IWebImagePanel ipWeb)
{View on GitHub (pinned to cb5d9c429c)
Solutions
- Always gate TryPrepare behind TryCanHandle(path) so only whitelisted extensions reach the switch.
- Keep the extension lists in the guard `if` and the switch in sync (extract a shared HashSet<string> of supported extensions).
- If hit during development, add the missing extension case or remove it from the guard.
- Catch NotSupportedException and return false from the plugin rather than crashing the preview.
Example fix
// before — duplicated lists drift apart
if (ext == ".svg" || ext == ".svga" /* ... */)
metaWeb = ext switch { /* ... */ _ => throw new NotSupportedException(...) };
// after — single source of truth
static readonly HashSet<string> WebExts = new(){".svg",".svga",".lottie",".json",".tgs",".gv",".dot",".pu",".puml",".plantuml",".wsd",".iuml",".drawio",".dio",".excalidraw"};
if (!WebExts.Contains(ext)) { metaWeb = null; return false; } Defensive patterns
Strategy: validation
Validate before calling
static readonly HashSet<string> WebExts = new(){".svg",".svga",".lottie",".json",".tgs",".gv",".dot",".pu",".puml",".plantuml",".wsd",".iuml",".drawio",".dio",".excalidraw"};
string ext = Path.GetExtension(path).ToLower();
if (!WebExts.Contains(ext)) return false; Type guard
static bool IsWebExt(string ext) => WebExts.Contains(ext);
Try / catch
try { if (!WebHandler.TryPrepare(path, ctx, out var meta)) { /* not handled */ } }
catch (NotSupportedException) { /* extension lists drifted; log and skip */ } Prevention
- Gate TryPrepare behind TryCanHandle.
- Keep a single shared extension set for guard and switch.
- Add new extensions to both the guard and the switch atomically.
When it happens
Trigger: Path.GetExtension(path).ToLower() returns a value not in the switch, AND the preceding guard `if` was bypassed (e.g. the lists are edited inconsistently, or TryPrepare is invoked directly without the guard).
Common situations: A new extension is added to the outer guard `if` but forgotten in the switch (or vice-versa); a caller invokes TryPrepare on a path it did not pre-screen with TryCanHandle.
Related errors
AI-assisted analysis of QL-Win/QuickLook@cb5d9c429c (2026-08-13).
Data as JSON: /api/errors/bc01d879de584949.
Report an issue: GitHub.