New Relic be like: *notices your errors* OwO what's this?

This commit is contained in:
Georg Gadinger 2020-04-28 20:32:36 +02:00
parent e07d069c73
commit 2f2b9ab1f4
8 changed files with 46 additions and 23 deletions

View File

@ -40,7 +40,8 @@ class Ajax::AnswerController < AjaxController
else else
current_user.answer question, params[:answer] current_user.answer question, params[:answer]
end end
rescue rescue => e
NewRelic::Agent.notice_error(e)
@response[:status] = :err @response[:status] = :err
@response[:message] = I18n.t('messages.error') @response[:message] = I18n.t('messages.error')
return return

View File

@ -7,7 +7,8 @@ class Ajax::CommentController < AjaxController
begin begin
current_user.comment(answer, params[:comment]) current_user.comment(answer, params[:comment])
rescue ActiveRecord::RecordInvalid rescue ActiveRecord::RecordInvalid => e
NewRelic::Agent.notice_error(e)
@response[:status] = :rec_inv @response[:status] = :rec_inv
@response[:message] = I18n.t('messages.comment.create.rec_inv') @response[:message] = I18n.t('messages.comment.create.rec_inv')
return return

View File

@ -6,7 +6,8 @@ class Ajax::FriendController < AjaxController
begin begin
current_user.follow target_user current_user.follow target_user
rescue rescue => e
NewRelic::Agent.notice_error(e)
@response[:status] = :fail @response[:status] = :fail
@response[:message] = I18n.t('messages.friend.create.fail') @response[:message] = I18n.t('messages.friend.create.fail')
return return
@ -24,7 +25,8 @@ class Ajax::FriendController < AjaxController
begin begin
current_user.unfollow target_user current_user.unfollow target_user
rescue rescue => e
NewRelic::Agent.notice_error(e)
@response[:status] = :fail @response[:status] = :fail
@response[:message] = I18n.t('messages.friend.destroy.fail') @response[:message] = I18n.t('messages.friend.destroy.fail')
return return

View File

@ -10,7 +10,8 @@ class Ajax::GroupController < AjaxController
begin begin
params.require :name params.require :name
rescue ActionController::ParameterMissing rescue ActionController::ParameterMissing => e
NewRelic::Agent.notice_error(e)
@response[:status] = :toolong @response[:status] = :toolong
@response[:message] = I18n.t('messages.group.create.noname') @response[:message] = I18n.t('messages.group.create.noname')
return return
@ -20,15 +21,18 @@ class Ajax::GroupController < AjaxController
begin begin
target_user = User.find_by_screen_name(params[:user]) target_user = User.find_by_screen_name(params[:user])
group = Group.create! user: current_user, display_name: params[:name] group = Group.create! user: current_user, display_name: params[:name]
rescue ActiveRecord::RecordInvalid rescue ActiveRecord::RecordInvalid => e
NewRelic::Agent.notice_error(e)
@response[:status] = :toolong @response[:status] = :toolong
@response[:message] = I18n.t('messages.group.create.toolong') @response[:message] = I18n.t('messages.group.create.toolong')
return return
rescue ActiveRecord::RecordNotFound rescue ActiveRecord::RecordNotFound => e
NewRelic::Agent.notice_error(e)
@response[:status] = :notfound @response[:status] = :notfound
@response[:message] = I18n.t('messages.group.create.notfound') @response[:message] = I18n.t('messages.group.create.notfound')
return return
rescue ActiveRecord::RecordNotUnique rescue ActiveRecord::RecordNotUnique => e
NewRelic::Agent.notice_error(e)
@response[:status] = :exists @response[:status] = :exists
@response[:message] = I18n.t('messages.group.create.exists') @response[:message] = I18n.t('messages.group.create.exists')
return return
@ -53,7 +57,8 @@ class Ajax::GroupController < AjaxController
begin begin
Group.where(user: current_user, name: params[:group]).first.destroy! Group.where(user: current_user, name: params[:group]).first.destroy!
rescue ActiveRecord::RecordNotFound rescue ActiveRecord::RecordNotFound => e
NewRelic::Agent.notice_error(e)
@response[:status] = :notfound @response[:status] = :notfound
@response[:message] = I18n.t('messages.group.destroy.notfound') @response[:message] = I18n.t('messages.group.destroy.notfound')
return return
@ -81,7 +86,8 @@ class Ajax::GroupController < AjaxController
begin begin
group = current_user.groups.find_by_name(params[:group]) group = current_user.groups.find_by_name(params[:group])
rescue ActiveRecord::RecordNotFound rescue ActiveRecord::RecordNotFound => e
NewRelic::Agent.notice_error(e)
@response[:status] = :notfound @response[:status] = :notfound
@response[:message] = I18n.t('messages.group.membership.notfound') @response[:message] = I18n.t('messages.group.membership.notfound')
return return

View File

@ -33,7 +33,8 @@ class Ajax::InboxController < AjaxController
begin begin
inbox.remove inbox.remove
rescue rescue => e
NewRelic::Agent.notice_error(e)
@response[:status] = :err @response[:status] = :err
@response[:message] = I18n.t('messages.error') @response[:message] = I18n.t('messages.error')
return return
@ -47,7 +48,8 @@ class Ajax::InboxController < AjaxController
def remove_all def remove_all
begin begin
Inbox.where(user: current_user).each { |i| i.remove } Inbox.where(user: current_user).each { |i| i.remove }
rescue rescue => e
NewRelic::Agent.notice_error(e)
@response[:status] = :err @response[:status] = :err
@response[:message] = I18n.t('messages.error') @response[:message] = I18n.t('messages.error')
return return
@ -64,7 +66,8 @@ class Ajax::InboxController < AjaxController
@inbox = current_user.inboxes.joins(:question) @inbox = current_user.inboxes.joins(:question)
.where(questions: { user_id: @target_user.id, author_is_anonymous: false }) .where(questions: { user_id: @target_user.id, author_is_anonymous: false })
@inbox.each { |i| i.remove } @inbox.each { |i| i.remove }
rescue rescue => e
NewRelic::Agent.notice_error(e)
@response[:status] = :err @response[:status] = :err
@response[:message] = I18n.t('messages.error') @response[:message] = I18n.t('messages.error')
return return

View File

@ -7,7 +7,8 @@ class Ajax::ModerationController < AjaxController
begin begin
current_user.report_vote(report, params[:upvote]) current_user.report_vote(report, params[:upvote])
rescue rescue => e
NewRelic::Agent.notice_error(e)
@response[:status] = :fail @response[:status] = :fail
@response[:message] = I18n.t('messages.moderation.vote.fail') @response[:message] = I18n.t('messages.moderation.vote.fail')
return return
@ -26,7 +27,8 @@ class Ajax::ModerationController < AjaxController
begin begin
current_user.report_unvote report current_user.report_unvote report
rescue rescue => e
NewRelic::Agent.notice_error(e)
@response[:status] = :fail @response[:status] = :fail
@response[:message] = I18n.t('messages.moderation.destroy_vote.fail') @response[:message] = I18n.t('messages.moderation.destroy_vote.fail')
return return
@ -46,7 +48,8 @@ class Ajax::ModerationController < AjaxController
begin begin
report.deleted = true report.deleted = true
report.save report.save
rescue rescue => e
NewRelic::Agent.notice_error(e)
@response[:status] = :fail @response[:status] = :fail
@response[:message] = I18n.t('messages.moderation.destroy_report.fail') @response[:message] = I18n.t('messages.moderation.destroy_report.fail')
return return
@ -66,7 +69,8 @@ class Ajax::ModerationController < AjaxController
begin begin
current_user.report_comment(report, params[:comment]) current_user.report_comment(report, params[:comment])
rescue ActiveRecord::RecordInvalid rescue ActiveRecord::RecordInvalid => e
NewRelic::Agent.notice_error(e)
@response[:status] = :rec_inv @response[:status] = :rec_inv
@response[:message] = I18n.t('messages.moderation.create_comment.rec_inv') @response[:message] = I18n.t('messages.moderation.create_comment.rec_inv')
return return

View File

@ -31,7 +31,8 @@ class Ajax::QuestionController < AjaxController
question = Question.create!(content: params[:question], question = Question.create!(content: params[:question],
author_is_anonymous: params[:anonymousQuestion], author_is_anonymous: params[:anonymousQuestion],
user: current_user) user: current_user)
rescue ActiveRecord::RecordInvalid rescue ActiveRecord::RecordInvalid => e
NewRelic::Agent.notice_error(e)
@response[:status] = :rec_inv @response[:status] = :rec_inv
@response[:message] = I18n.t('messages.question.create.rec_inv') @response[:message] = I18n.t('messages.question.create.rec_inv')
return return
@ -50,7 +51,8 @@ class Ajax::QuestionController < AjaxController
begin begin
current_user.groups.find_by_name!(params[:rcpt].sub 'grp:', '') current_user.groups.find_by_name!(params[:rcpt].sub 'grp:', '')
QuestionWorker.perform_async params[:rcpt], current_user.id, question.id QuestionWorker.perform_async params[:rcpt], current_user.id, question.id
rescue ActiveRecord::RecordNotFound rescue ActiveRecord::RecordNotFound => e
NewRelic::Agent.notice_error(e)
@response[:status] = :not_found @response[:status] = :not_found
@response[:message] = I18n.t('messages.question.create.not_found') @response[:message] = I18n.t('messages.question.create.not_found')
return return

View File

@ -6,7 +6,8 @@ class Ajax::SmileController < AjaxController
begin begin
current_user.smile answer current_user.smile answer
rescue rescue => e
NewRelic::Agent.notice_error(e)
@response[:status] = :fail @response[:status] = :fail
@response[:message] = I18n.t('messages.smile.create.fail') @response[:message] = I18n.t('messages.smile.create.fail')
return return
@ -24,7 +25,8 @@ class Ajax::SmileController < AjaxController
begin begin
current_user.unsmile answer current_user.unsmile answer
rescue rescue => e
NewRelic::Agent.notice_error(e)
@response[:status] = :fail @response[:status] = :fail
@response[:message] = I18n.t('messages.smile.destroy.fail') @response[:message] = I18n.t('messages.smile.destroy.fail')
return return
@ -42,7 +44,8 @@ class Ajax::SmileController < AjaxController
begin begin
current_user.smile_comment comment current_user.smile_comment comment
rescue rescue => e
NewRelic::Agent.notice_error(e)
@response[:status] = :fail @response[:status] = :fail
@response[:message] = I18n.t('messages.smile.create_comment.fail') @response[:message] = I18n.t('messages.smile.create_comment.fail')
return return
@ -60,7 +63,8 @@ class Ajax::SmileController < AjaxController
begin begin
current_user.unsmile_comment comment current_user.unsmile_comment comment
rescue rescue => e
NewRelic::Agent.notice_error(e)
@response[:status] = :fail @response[:status] = :fail
@response[:message] = I18n.t('messages.smile.destroy_comment.fail') @response[:message] = I18n.t('messages.smile.destroy_comment.fail')
return return