Closed dudo closed 4 years ago
I'm trying to rescue from particular exceptions, to add some resiliency to my services with...
# frozen_string_literal: true module HandlesError extend ActiveSupport::Concern included do include ActiveSupport::Rescuable rescue_from StandardError, with: :handle_exception rescue_from ArgumentError, with: :handle_exception rescue_from ActiveRecord::RecordNotFound, with: :not_found end protected def not_found(exception) handle_exception(exception, code: :not_found) end def handle_exception(exception, code: :internal_server_error) context.status_code = Rack::Utils.status_code(code) context.message ||= exception.to_s.humanize context.fail! end end
I'm including that in my service via include HandlesError.
include HandlesError
I know from your readme that .call swallows errors. Could we move where that happens, so that we can react to internal failures more gracefully?
.call
I found that using this from the controllers was sufficient, and capturing the errors within the service was moot. Disregard!
I'm trying to rescue from particular exceptions, to add some resiliency to my services with...
I'm including that in my service via
include HandlesError
.I know from your readme that
.call
swallows errors. Could we move where that happens, so that we can react to internal failures more gracefully?