Return different responses for use case errors

This commit is contained in:
Karina Kwiatek 2022-01-24 22:42:46 +01:00 committed by Karina Kwiatek
parent 22a66f4d1a
commit 1216c249e8
2 changed files with 13 additions and 0 deletions

View File

@ -20,6 +20,18 @@ class AjaxController < ApplicationController
end
end
rescue_from(Errors::Base) do |e|
Sentry.capture_exception(e)
@response = {
success: false,
message: e.message,
status: e.code
}
return_response
end
rescue_from(KeyError) do |e|
Sentry.capture_exception(e)

View File

@ -1,6 +1,7 @@
# frozen_string_literal: true
require "use_case/base"
require "errors"
module UseCase
module Question