Avoid swallowing exceptions unnecessarily.

This commit is contained in:
evazion
2019-08-29 00:24:00 -05:00
parent eba6440b8b
commit d73895312e
7 changed files with 7 additions and 24 deletions

View File

@@ -10,9 +10,6 @@ module Admin
@importer.process! @importer.process!
flash[:notice] = "Import queued" flash[:notice] = "Import queued"
redirect_to new_admin_alias_and_implication_import_path redirect_to new_admin_alias_and_implication_import_path
rescue => x
flash[:notice] = x.to_s
redirect_to new_admin_alias_and_implication_import_path
end end
end end
end end

View File

@@ -1,6 +1,5 @@
class CountsController < ApplicationController class CountsController < ApplicationController
respond_to :xml, :json respond_to :xml, :json
rescue_from Post::TimeoutError, with: :rescue_exception
def posts def posts
@count = Post.fast_count( @count = Post.fast_count(

View File

@@ -39,8 +39,6 @@ module Moderator
def expunge def expunge
@post = ::Post.find(params[:id]) @post = ::Post.find(params[:id])
@post.expunge! @post.expunge!
rescue StandardError => x
@error = x
end end
def confirm_ban def confirm_ban

View File

@@ -51,6 +51,7 @@ class UserUpgradesController < ApplicationController
@user.promote_to!(level, is_upgrade: true) @user.promote_to!(level, is_upgrade: true)
flash[:success] = true flash[:success] = true
rescue Stripe::CardError => e rescue Stripe::CardError => e
DanbooruLogger.log(e)
flash[:error] = e.message flash[:error] = e.message
end end

View File

@@ -416,14 +416,10 @@ class Artist < ApplicationRecord
ti = TagImplication.where(:antecedent_name => name, :consequent_name => "banned_artist").first ti = TagImplication.where(:antecedent_name => name, :consequent_name => "banned_artist").first
ti.destroy if ti ti.destroy if ti
begin Post.tag_match(name).where("true /* Artist.unban */").each do |post|
Post.tag_match(name).where("true /* Artist.unban */").each do |post| post.unban!
post.unban! fixed_tags = post.tag_string.sub(/(?:\A| )banned_artist(?:\Z| )/, " ").strip
fixed_tags = post.tag_string.sub(/(?:\A| )banned_artist(?:\Z| )/, " ").strip post.update(tag_string: fixed_tags)
post.update(tag_string: fixed_tags)
end
rescue Post::SearchError
# swallow
end end
update_column(:is_banned, false) update_column(:is_banned, false)
@@ -435,12 +431,8 @@ class Artist < ApplicationRecord
def ban! def ban!
Post.transaction do Post.transaction do
CurrentUser.without_safe_mode do CurrentUser.without_safe_mode do
begin Post.tag_match(name).where("true /* Artist.ban */").each do |post|
Post.tag_match(name).where("true /* Artist.ban */").each do |post| post.ban!
post.ban!
end
rescue Post::SearchError
# swallow
end end
# potential race condition but unlikely # potential race condition but unlikely

View File

@@ -101,8 +101,6 @@ class SavedSearch < ApplicationRecord
redis.sadd(redis_key, post_ids) redis.sadd(redis_key, post_ids)
redis.expire(redis_key, REDIS_EXPIRY) redis.expire(redis_key, REDIS_EXPIRY)
end end
rescue Exception
# swallow
end end
end end
end end

View File

@@ -2,8 +2,6 @@ module PostSetPresenters
class WikiPage < PostSetPresenters::Post class WikiPage < PostSetPresenters::Post
def posts def posts
@post_set.posts @post_set.posts
rescue ActiveRecord::StatementInvalid, PG::Error
[]
end end
def post_previews_html(template) def post_previews_html(template)