Improve error handling for unknown sprite icons
<!--IssueSummary start--> <details> <summary> Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards. </summary> - [Work on this issue](https://contributors.gitlab.com/manage-issue?action=work&projectId=278964&issueIid=424986) - [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=424986) </details> <!--IssueSummary end--> ### Summary See [this thread](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/131260#note_1555445906) for context. Currently, in the [icons_helper.rb](https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/helpers/icons_helper.rb#L178) we will throw an error on non-production environments if an icon is not found. ```ruby def known_sprites return if Rails.env.production? @known_sprites ||= Gitlab::Json.parse(File.read(Rails.root.join('node_modules/@gitlab/svgs/dist/icons.json')))['icons'] end def known_file_icon_sprites return if Rails.env.production? @known_file_icon_sprites ||= Gitlab::Json.parse(File.read(Rails.root.join('node_modules/@gitlab/svgs/dist/file_icons/file_icons.json')))['icons'] end ``` Ideally, we should avoid the production check and see if there's a more graceful way to fail regardless of the environment.
issue