]> cat aescling's git repositories - mastodon.git/commitdiff
Meaningful validation errors in API response
authorEugen Rochko <eugen@zeonfederated.com>
Fri, 30 Sep 2016 20:31:16 +0000 (22:31 +0200)
committerEugen Rochko <eugen@zeonfederated.com>
Fri, 30 Sep 2016 20:31:16 +0000 (22:31 +0200)
app/controllers/api_controller.rb

index e3ac9fc67e2b4a1a9121aac82bf9d6ef990c4a1e..c550b38e8e4d4ea346ce1cab8e1633bcd8df481d 100644 (file)
@@ -2,8 +2,8 @@ class ApiController < ApplicationController
   protect_from_forgery with: :null_session
   skip_before_action :verify_authenticity_token
 
-  rescue_from ActiveRecord::RecordInvalid do
-    render json: { error: 'Record invalid' }, status: 422
+  rescue_from ActiveRecord::RecordInvalid do |e|
+    render json: { error: e.to_s }, status: 422
   end
 
   rescue_from ActiveRecord::RecordNotFound do