Wiki controller responds with 500 when it should respond with a 40x error

Requests to the wiki pages endpoints to retrieve JSON will fail to find the required templates and raise internal server errors. This is noise, because we do not serve JSON from this controller, but we should respond with a 404/406 just to remove these errors from our logs and also lighten the server load, since we can detect this very early and return quickly.

https://sentry.gitlab.net/gitlab/gitlabcom/issues/1280565/?referrer=gitlab_plugin

ActionView::MissingTemplate: Missing template projects/wikis/empty, projects/application/empty, application/empty with {:locale=>[:en], :formats=>[:json], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :haml]}. Searched in:
  * "/opt/gitlab/embedded/service/gitlab-rails/ee/app/views"
  * "/opt/gitlab/embedded/service/gitlab-rails/app/views"
  * "/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/peek-1.1.0/app/views"
  * "/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/kaminari-core-1.0.1/app/views"
  * "/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/graphiql-rails-1.4.10/app/views"
  * "/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/doorkeeper-5.0.2/app/views"
  * "/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/devise-4.7.1/app/views"

  action_view/path_set.rb:48:in `find'
    find_all(*args).first || raise(MissingTemplate.new(self, *args))
  action_view/lookup_context.rb:129:in `find'
    @view_paths.find(*args_for_lookup(name, prefixes, partial, keys, options))
  action_view/renderer/template_renderer.rb:47:in `determine_template'
    @lookup_context.find_template(options[:template], options[:prefixes], false, keys, @details)
  action_view/renderer/template_renderer.rb:9:in `render'
    template = determine_template(options)
  action_view/renderer/renderer.rb:61:in `render_template_to_object'
    TemplateRenderer.new(@lookup_context).render(context, options)
...
(158 additional frame(s) were not displayed)

ActionView::MissingTemplate: Missing template projects/wikis/empty, projects/application/empty, application/empty with {:locale=>[:en], :formats=>[:json], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :haml]}. Searched in:
  * "/opt/gitlab/embedded/service/gitlab-rails/ee/app/views"
  * "/opt/gitlab/embedded/service/gitlab-rails/app/views"
  * "/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/peek-1.1.0/app/views"
  * "/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/kaminari-core-1.0.1/app/views"
  * "/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/graphiql-rails-1.4.10/app/views"
  * "/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/doorkeeper-5.0.2/app/views"
  * "/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/devise-4.7.1/app/views"
Edited by Markus Koller