-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Silent Error Handling in Fluxus::Safe::Caller Reduces Error Visibility #14
Comments
PayWithCreditCard.
call(credit_card: my_cc_object, payment_gateway_wrapper: my_wrapper)
on_success { |result| invoke_checkout_success(result) }.
on_exception(MyGateway::InsuficientFunds) { |result| invoke_checkout_failure(result) }
on_exception(MyGateway::FraudulentOperation) { |result| invoke_operational_fraud_and_report(result) }.
on_failure { |result| invoke_unexpected_failure(result) } Not-mapped errors will always invoke failures, and guarantee the Ruby runtime continuity by taking wrapping the error in a "sandboxed" object. If you do not properly handle the If need to use the "let it crash" approach I strongly recommend you use the common |
Thank you for the detailed explanation. I understand the design philosophy behind A suggestion would be to add a configurable logger in
this add the possibility to configure a logger in Rails for example:
|
@ViniMoraes I see your concerns, and I'm open to evaluating a pull request implementing the proposed idea!
Following those suggestions we are good to have it. |
Another proposal based on Sidekiq implementation of # config/initializers/fluxus.rb
Fluxus::Safe::Caller.exception_handler = ->(exception) { ... } module Fluxus
module Safe
class Caller < Runner
class << self
attr_writer :logger
def logger
@logger ||= Logger.new($stdout)
end
end
def self.call!(...)
instance = new
__call__(instance, ...)
rescue StandardError => e
raise e if e.is_a?(ResultTypeNotDefinedError)
exception_handler.call(e) unless exception_handler.nil?
instance.Failure(type: :exception, result: { exception: e })
end
end
end
end |
The Fluxus::Safe::Caller class handles errors by silencing them, which can lead to a lack of visibility into underlying issues. This behavior can make debugging difficult as errors are not logged or raised, potentially leading to unexpected behavior without a clear indication of the cause.
Proposed Solution:
Impact:
Improving error visibility will help developers identify and fix issues more efficiently, leading to more robust and maintainable code.
The text was updated successfully, but these errors were encountered: