]> cat aescling's git repositories - mastodon.git/commitdiff
Fix REST API sometimes returning HTML on error (#19135)
authorClaire <claire.github-309c@sitedethib.com>
Thu, 8 Sep 2022 07:44:36 +0000 (09:44 +0200)
committeraescling <aescling+gitlab@cat.family>
Thu, 17 Nov 2022 02:59:19 +0000 (21:59 -0500)
Fixes #19115

app/controllers/api/base_controller.rb

index 2e393fbb6f4d0fdcfe3be8cbe72d922753dc7010..7ce6599c525b1334b9200062cf5513c16eb30fe3 100644 (file)
@@ -131,4 +131,10 @@ class Api::BaseController < ApplicationController
   def disallow_unauthenticated_api_access?
     authorized_fetch_mode?
   end
+
+  private
+
+  def respond_with_error(code)
+    render json: { error: Rack::Utils::HTTP_STATUS_CODES[code] }, status: code
+  end
 end