{"record":{"id":"3ad1809d22e0a0ee","repo":"SubtitleEdit/subtitleedit","slug":"ocr-engine-options-ocrengine-is-not-supported","errorCode":null,"errorMessage":"OCR engine '{options.OcrEngine}' is not supported. Use one of: tesseract, nocr, binaryocr, ollama, llamacpp, paddle.","messagePattern":"OCR engine '(.+?)' is not supported\\. Use one of: tesseract, nocr, binaryocr, ollama, llamacpp, paddle\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/seconv/Core/OcrEngineFactory.cs","lineNumber":21,"sourceCode":"/// <summary>\n/// Creates an <see cref=\"IOcrEngine\"/> from CLI options. Throws with a clear message when\n/// the requested engine is unsupported or its prerequisites (binary on PATH, database file)\n/// aren't satisfied.\n/// </summary>\ninternal static class OcrEngineFactory\n{\n    public static IOcrEngine Create(ConversionOptions options)\n    {\n        var engine = (options.OcrEngine ?? \"tesseract\").Trim().ToLowerInvariant();\n        return engine switch\n        {\n            \"tesseract\" or \"\" => TesseractOcrEngine.Create(options.OcrLanguage),\n            \"nocr\" => new NOcrOcrEngine(ResolveOcrDbPath(options, \"nocr\", \".nocr\")),\n            \"binaryocr\" or \"binary\" => new BinaryOcrOcrEngine(ResolveOcrDbPath(options, \"binaryocr\", \".db\")),\n            \"ollama\" => new OllamaOcrEngine(options.OllamaUrl, options.OllamaModel, options.OcrLanguage),\n            \"llamacpp\" or \"llama.cpp\" or \"llama\" => LlamaCppOcrEngine.Create(options),\n            \"paddle\" or \"paddleocr\" => PaddleOcrEngine.Create(options.OcrLanguage),\n            _ => throw new InvalidOperationException(\n                $\"OCR engine '{options.OcrEngine}' is not supported. Use one of: tesseract, nocr, binaryocr, ollama, llamacpp, paddle.\")\n        };\n    }\n\n    private static string ResolveOcrDbPath(ConversionOptions options, string engineName, string requiredExtension)\n    {\n        if (string.IsNullOrWhiteSpace(options.OcrDb))\n        {\n            var displayExt = requiredExtension.TrimStart('.');\n            throw new InvalidOperationException(\n                $\"{engineName} engine requires --ocr-db=<path-to-Latin{requiredExtension}> (or another {requiredExtension} file). \" +\n                $\"Find them in `%AppData%\\\\Subtitle Edit\\\\OCR\\\\` or download from the SE UI.\");\n        }\n        var path = options.OcrDb;\n        if (!path.EndsWith(requiredExtension, StringComparison.OrdinalIgnoreCase))\n        {\n            path += requiredExtension;\n        }","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/seconv/Core/OcrEngineFactory.cs#L3-L39","documentation":"Thrown by OcrEngineFactory.Create when the requested engine name (after trim + lowercase) matches none of the supported arms in its switch. The factory is the single dispatch point for the `--ocr-engine` CLI option; an unknown name is a user/CLI typo, not a recoverable runtime condition.","triggerScenarios":"Calling `OcrEngineFactory.Create(options)` with `options.OcrEngine` set to a value outside {tesseract, '', nocr, binaryocr, binary, ollama, llamacpp, llama.cpp, llama, paddle, paddleocr}. Example misspellings: 'tessaract', 'ocr', 'google', 'azure'.","commonSituations":"Typoing the engine name on the command line; copy-pasting a deprecated engine name from old docs; a wrapper script passing an uppercase or differently-cased name that should still work (it is lowercased, so this is rare).","solutions":["Use one of the listed engines: tesseract, nocr, binaryocr, ollama, llamacpp, paddle.","Check for trailing whitespace or quotes around the --ocr-engine value.","If using a settings file, ensure the `ocrEngine` key uses a supported value.","Run `seconv --help` to confirm the engine list for your seconv version."],"exampleFix":"// before\nseconv in.sup out.srt --ocr-engine tessaract\n// after\nseconv in.sup out.srt --ocr-engine tesseract","handlingStrategy":"validation","validationCode":"static readonly HashSet<string> ValidEngines = new(StringComparer.OrdinalIgnoreCase)\n{ \"tesseract\", \"\", \"nocr\", \"binaryocr\", \"binary\", \"ollama\", \"llamacpp\", \"llama.cpp\", \"llama\", \"paddle\", \"paddleocr\" };\nif (!ValidEngines.Contains(options.OcrEngine ?? \"tesseract\"))\n    throw new ArgumentException(\"Unsupported OCR engine: \" + options.OcrEngine);","typeGuard":"static bool IsValidOcrEngine(string? e) =>\n    ValidEngines.Contains((e ?? \"tesseract\").Trim().ToLowerInvariant());","tryCatchPattern":"try { var engine = OcrEngineFactory.Create(options); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"is not supported\"))\n{\n    // print supported list, exit usage error\n}","preventionTips":["Whitelist OCR engine names at CLI parse time.","Document the canonical lower-case names and normalise input casing before dispatch.","Add a unit test enumerating each accepted alias."],"tags":["ocr","cli","configuration","enum-validation"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}