{"record":{"id":"2030aef706f14042","repo":"d2phap/ImageGlass","slug":"frame-index-frameindexstr-is-not-a-valid-integ","errorCode":null,"errorMessage":"Frame index '{frameIndexStr}' is not a valid integer.\n\n----------\n👉🏼 Method: IG_ViewFrame","messagePattern":"Frame index '(.+?)' is not a valid integer\\.\n\n----------\n👉🏼 Method: IG_ViewFrame","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"source/ImageGlass.Lib/Common/ServiceProviders/AppAPIs/AppAPIProvider.cs","lineNumber":1095,"sourceCode":"\n\n    /// <summary>\n    /// Views the last photo in the list.\n    /// </summary>\n    public void IG_GoToLast()\n    {\n        IG_ViewByIndex((int)Core.Photos.Count - 1);\n    }\n\n\n    /// <summary>\n    /// View a frame of the current photo.\n    /// </summary>\n    public void IG_ViewFrame(string? frameIndexStr)\n    {\n        if (!int.TryParse(frameIndexStr, out var frameIndex))\n        {\n            throw new ArgumentException($\"\"\"\n                Frame index '{frameIndexStr}' is not a valid integer.\n\n                ----------\n                👉🏼 Method: {nameof(IG_ViewFrame)}\n                \"\"\",\n                nameof(frameIndexStr));\n        }\n\n        IG_ViewFrame(frameIndex);\n    }\n\n\n    /// <summary>\n    /// View a frame of the current photo.\n    /// If the frame index is out of range, it will be looped.\n    /// </summary>\n    public static void IG_ViewFrame(int frameIndex)\n    {","sourceCodeStart":1077,"sourceCodeEnd":1113,"githubUrl":"https://github.com/d2phap/ImageGlass/blob/4a3c4feceffc5a8bb5e56ba836509634aaae47a9/source/ImageGlass.Lib/Common/ServiceProviders/AppAPIs/AppAPIProvider.cs#L1077-L1113","documentation":"Thrown by the string overload of IG_ViewFrame when int.TryParse(frameIndexStr) fails. The method parses a frame index for a multi-frame photo (GIF/WEBP animation) before delegating to the int overload. Out-of-range indices are looped safely downstream; only a non-integer string throws here.","triggerScenarios":"Calling IG_ViewFrame(string) with a non-numeric frame index: 'first', '2.5', '' , or a string with whitespace.","commonSituations":"Hotkey bound to a frame navigation command with a non-numeric argument; script passing a label instead of an index; current photo is single-frame (the int overload returns early, but the string parse happens first).","solutions":["Pass a plain integer string for the frame index ('0', '1', '2', ...).","Validate with int.TryParse upstream and call the int overload directly.","Trim and reject empty input before invoking."],"exampleFix":"// before\napi.IG_ViewFrame(userInput);\n\n// after\nif (int.TryParse(userInput?.Trim(), out var frame))\n{\n    api.IG_ViewFrame(frame);\n}","handlingStrategy":"validation","validationCode":"if (!int.TryParse(frameIndexStr?.Trim(), out var frame))\n    throw new ArgumentException(\"Frame index must be an integer.\");\napi.IG_ViewFrame(frame);","typeGuard":"static bool IsValidFrameIndex(string? s) => int.TryParse(s?.Trim(), out _);","tryCatchPattern":"try { api.IG_ViewFrame(frameIndexStr); }\ncatch (ArgumentException ex) when (ex.ParamName == nameof(frameIndexStr))\n{ /* reject the input */ }","preventionTips":["Pass plain integer strings for the frame index.","Validate upstream with int.TryParse and call the int overload.","Trim user input before parsing."],"tags":["app-api","animation","argument-parsing","integer"],"backgroundTag":null,"analyzedSha":"4a3c4feceffc5a8bb5e56ba836509634aaae47a9","analyzedAt":"2026-08-13T16:58:15.523Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}