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
current_user.answer question, params[:answer]
end
rescue
rescue => e
NewRelic::Agent.notice_error(e)
@response[:status] = :err
@response[:message] = I18n.t('messages.error')
return

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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