about summary refs log tree commit diff
path: root/app/controllers/api_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/api_controller.rb')
-rw-r--r--app/controllers/api_controller.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb
index 8a2712476..bacdd997b 100644
--- a/app/controllers/api_controller.rb
+++ b/app/controllers/api_controller.rb
@@ -2,6 +2,14 @@ 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
+  end
+
+  rescue_from ActiveRecord::RecordNotFound do
+    render json: { error: 'Record not found' }, status: 404
+  end
+
   protected
 
   def current_resource_owner