{"record":{"id":"f4af8f82482379d1","repo":"tui-cs/Terminal.Gui","slug":"value-was-not-composed-entirely-of-decimal-digits","errorCode":null,"errorMessage":"Value was not composed entirely of decimal digits.","messagePattern":"Value was not composed entirely of decimal digits\\.","errorType":"validation","errorClass":"ColorParseException","httpStatus":null,"severity":"error","filePath":"Terminal.Gui/Drawing/Color/Color.Formatting.cs","lineNumber":390,"sourceCode":"\n                        return new Color (int.Parse (rSpan), int.Parse (gSpan), int.Parse (bSpan));\n                    }\n                case 4:\n                    {\n                        // rgba(r,g,b,a)\n                        ParseRgbValues (\n                                        in valuesSubstring,\n                                        in valueRanges,\n                                        in originalString,\n                                        out ReadOnlySpan<char> rSpan,\n                                        out ReadOnlySpan<char> gSpan,\n                                        out ReadOnlySpan<char> bSpan\n                                       );\n                        ReadOnlySpan<char> aSpan = valuesSubstring [valueRanges [3]];\n\n                        if (!aSpan.IsAllAsciiDigits ())\n                        {\n                            throw new ColorParseException (\n                                                           in originalString,\n                                                           \"Value was not composed entirely of decimal digits.\",\n                                                           in aSpan,\n                                                           nameof (A)\n                                                          );\n                        }\n\n                        return new Color (int.Parse (rSpan), int.Parse (gSpan), int.Parse (bSpan), int.Parse (aSpan));\n                    }\n                default:\n                    throw new ColorParseException (\n                                                   in originalString,\n                                                   $\"Wrong number of values. Expected 3 or 4 decimal integers. Got {rangeCount}.\",\n                                                   in originalString\n                                                  );\n            }\n\n            [Pure]","sourceCodeStart":372,"sourceCodeEnd":408,"githubUrl":"https://github.com/tui-cs/Terminal.Gui/blob/2e47b11478db083499917f2ad27c34d30efb0df1/Terminal.Gui/Drawing/Color/Color.Formatting.cs#L372-L408","documentation":"Thrown inside ParseRgbaFormat when an rgb()/rgba() string contains 4 comma-separated values but the alpha (4th) component is not composed entirely of ASCII decimal digits. It is a ColorParseException whose BadValue is the alpha substring and BadValueName is \"A\". This pinpoints the alpha channel as the offending component.","triggerScenarios":"Passing \"rgb(10,20,30,-5)\" (negative sign is not a digit), \"rgb(10,20,30,0x10)\" (hex), or \"rgb(10,20,30,2.5)\" (decimal point). Only unsigned integer decimals are accepted.","commonSituations":"Passing alpha as a float (common in CSS where alpha is 0..1), negative values, or hex notation inside an rgb() string.","solutions":["Ensure the alpha value is a non-negative integer string of digits only.","If your source alpha is a 0..1 float, convert it to 0..255 integer first.","Use Color.TryParse to catch the malformed rgba input."],"exampleFix":"// before\nColor c = Color.Parse($\"rgb({r},{g},{b},{alphaFloat})\");\n\n// after\nint alphaByte = (int)Math.Round(alphaFloat * 255);\nColor c = Color.Parse($\"rgb({r},{g},{b},{alphaByte})\");","handlingStrategy":"validation","validationCode":"string a = alphaSpan.ToString();\nif (!a.AsSpan().IsAllAsciiDigits()) return fallbackColor;","typeGuard":"static bool IsValidAlphaComponent(string s) => s.AsSpan().IsAllAsciiDigits() && int.Parse(s) is >= 0 and <= 255;","tryCatchPattern":"try { c = Color.Parse($\"rgb({r},{g},{b},{a})\"); } catch (ColorParseException ex) { /* ex.BadValueName == \"A\" */ c = fallback; }","preventionTips":["Express alpha as an integer 0..255, not a 0..1 float.","Avoid negative or hex alpha values inside rgb().","Use Color.TryParse for user-built rgb strings."],"tags":["color","parsing","rgb","alpha-channel","format-exception"],"backgroundTag":null,"analyzedSha":"2e47b11478db083499917f2ad27c34d30efb0df1","analyzedAt":"2026-08-13T19:20:08.826Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}