{"record":{"id":"285839665f613b31","repo":"d2phap/ImageGlass","slug":"optionstr-is-not-a-valid-rotation-option","errorCode":null,"errorMessage":"'{optionStr}' is not a valid rotation option.\n\n----------\n👉🏼 Method: IG_Rotate","messagePattern":"'(.+?)' is not a valid rotation option\\.\n\n----------\n👉🏼 Method: IG_Rotate","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"source/ImageGlass.Lib/Common/ServiceProviders/AppAPIs/AppAPIProvider.cs","lineNumber":1776,"sourceCode":"        if (enabled.Value)\n        {\n            Viewer.StartAnimator();\n        }\n        else\n        {\n            Viewer.StopAnimator();\n        }\n    }\n\n\n    /// <summary>\n    /// Rotate the current image according to the rotation options.\n    /// </summary>\n    public void IG_Rotate(string? optionStr)\n    {\n        if (!Enum.TryParse<RotateOption>(optionStr, out var options))\n        {\n            throw new ArgumentException($\"\"\"\n                '{optionStr}' is not a valid rotation option.\n\n                ----------\n                👉🏼 Method: {nameof(IG_Rotate)}\n                \"\"\",\n                nameof(optionStr));\n        }\n\n        IG_Rotate(options);\n    }\n\n\n    /// <summary>\n    /// Rotate the current image according to the rotation options.\n    /// </summary>\n    public static void IG_Rotate(RotateOption options)\n    {\n        if (Viewer.SourceKind == PhotoSource.None || Core.IsBusy) return;","sourceCodeStart":1758,"sourceCodeEnd":1794,"githubUrl":"https://github.com/d2phap/ImageGlass/blob/4a3c4feceffc5a8bb5e56ba836509634aaae47a9/source/ImageGlass.Lib/Common/ServiceProviders/AppAPIs/AppAPIProvider.cs#L1758-L1794","documentation":"Thrown by the string overload of IG_Rotate when Enum.TryParse<RotateOption>(optionStr) fails. RotateOption has only two members, case-insensitively parsed: Left (rotate -90) and Right (rotate +90). Any other string raises ArgumentException.","triggerScenarios":"Calling IG_Rotate(string) with 'left'/'right' in another language, '90'/'-90' as a non-numeric label, 'cw'/'ccw', 'rotate-left', or any value other than Left/Right.","commonSituations":"Config with a descriptive label instead of the enum name; localized user input; legacy v9 keyword; trailing whitespace.","solutions":["Use exactly 'Left' or 'Right' (case-insensitive).","Validate with Enum.TryParse<RotateOption> upstream and call the typed overload.","Map common aliases ('cw' -> Right, 'ccw' -> Left, '90' -> Right, '-90' -> Left) before calling."],"exampleFix":"// before\napi.IG_Rotate(userInput);\n\n// after\nif (Enum.TryParse<RotateOption>(userInput?.Trim(), true, out var opt))\n{\n    api.IG_Rotate(opt);\n}","handlingStrategy":"validation","validationCode":"if (!Enum.TryParse<RotateOption>(optionStr?.Trim(), true, out var opt))\n    throw new ArgumentException($\"Unknown rotation option '{optionStr}'.\");\napi.IG_Rotate(opt);","typeGuard":"static bool IsValidRotateOption(string? s) => Enum.TryParse<RotateOption>(s?.Trim(), true, out _);","tryCatchPattern":"try { api.IG_Rotate(optionStr); }\ncatch (ArgumentException ex) when (ex.ParamName == nameof(optionStr))\n{ /* valid: Left, Right */ }","preventionTips":["Use exactly 'Left' or 'Right'.","Map 'cw'/'ccw'/'90'/'-90' upstream.","Validate with Enum.TryParse<RotateOption> before calling."],"tags":["app-api","rotate","argument-parsing","enum"],"backgroundTag":null,"analyzedSha":"4a3c4feceffc5a8bb5e56ba836509634aaae47a9","analyzedAt":"2026-08-13T16:58:15.523Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}