{"record":{"id":"e3da267d4d98ab4a","repo":"rouge-ruby/rouge","slug":"invalid-color-color","errorCode":null,"errorMessage":"invalid color: #{color}","messagePattern":"invalid color: #(.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"lib/rouge/formatters/terminal256.rb","lineNumber":138,"sourceCode":"        def escape(attrs)\n          return '' if attrs.empty?\n          \"\\e[#{attrs.join(';')}m\"\n        end\n\n        def self.color_index(color)\n          @color_index_cache ||= {}\n          @color_index_cache[color] ||= closest_color(*get_rgb(color))\n        end\n\n        def self.get_rgb(color)\n          color = $1 if color =~ /#([0-9a-f]+)/i\n          hexes = case color.size\n          when 3\n            color.chars.map { |c| \"#{c}#{c}\" }\n          when 6\n            color.scan(/../)\n          else\n            raise \"invalid color: #{color}\"\n          end\n\n          hexes.map { |h| h.to_i(16) }\n        end\n\n        def self.closest_color(r, g, b)\n          @@colors_cache ||= {}\n          key = (r << 16) + (g << 8) + b\n          @@colors_cache.fetch(key) do\n            distance = MAX_DISTANCE\n\n            match = 0\n\n            xterm_colors.each_with_index do |(cr, cg, cb), i|\n              d = (r - cr)**2 + (g - cg)**2 + (b - cb)**2\n              next if d >= distance\n\n              match = i","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/rouge-ruby/rouge/blob/bd7dad7b0939c556e582a0370686f6fc022c8af5/lib/rouge/formatters/terminal256.rb#L120-L156","documentation":"Error \"invalid color: #{color}\" thrown in rouge-ruby/rouge.","triggerScenarios":"Thrown at lib/rouge/formatters/terminal256.rb:138 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"bd7dad7b0939c556e582a0370686f6fc022c8af5","analyzedAt":"2026-08-23T11:34:50.713Z","schemaVersion":2},"datasetVersion":"2026-08-23T16:17:53.355Z"}