Merge branch '1495-crunch-documentation'
[arvados.git] / services / api / app / controllers / application_controller.rb
index 2f07c394609a7664abec7a88630fd48c6b308c83..434b09572b40b64af026e27a43962b422aeea7c6 100644 (file)
@@ -69,7 +69,7 @@ class ApplicationController < ActionController::Base
     :with => :render_not_found
     rescue_from ActionController::UnknownController,
     :with => :render_not_found
-    rescue_from ActionController::UnknownAction,
+    rescue_from AbstractController::ActionNotFound,
     :with => :render_not_found
     rescue_from ArvadosModel::PermissionDeniedError,
     :with => :render_error
@@ -83,7 +83,8 @@ class ApplicationController < ActionController::Base
     else
       errors = [e.inspect]
     end
-    render json: { errors: errors }, status: 422
+    status = e.respond_to?(:http_status) ? e.http_status : 422
+    render json: { errors: errors }, status: status
   end
 
   def render_not_found(e=ActionController::RoutingError.new("Path not found"))
@@ -354,4 +355,9 @@ class ApplicationController < ActionController::Base
       order: { type: 'string', required: false }
     }
   end
+  
+  def client_accepts_plain_text_stream
+    (request.headers['Accept'].split(' ') &
+     ['text/plain', '*/*']).count > 0
+  end
 end