favorites: fix error handling.

* Return HTTP 422 instead of HTTP 500 on "You have already favorited
  this post" errors.

* Log unexpected errors in Ajax requests to the console.
This commit is contained in:
evazion
2019-08-13 21:30:20 -05:00
parent ca2e2c92b9
commit 00239c4901
3 changed files with 16 additions and 1 deletions

View File

@@ -2,6 +2,7 @@ class FavoritesController < ApplicationController
before_action :member_only, except: [:index]
respond_to :html, :xml, :json, :js
skip_before_action :api_check
rescue_with Favorite::Error, status: 422
def index
if params[:tags]