Ir al contenido

Broad Exception Catch (ARCH6153)

Esta página aún no está disponible en tu idioma.

Key ruby.logging.broad-rescue · Severity info · Category logging

Catching the most general exception type (Exception, StandardError) also masks unexpected, unrelated failures. This hides real problems.

def process(order)
charge(order)
rescue Exception => e
Rails.logger.error(e.message)
end
def process(order)
charge(order)
rescue PaymentError, Net::TimeoutError => e
Rails.logger.error("Payment failed: #{order.id}", exception: e)
end

Rescue only the specific exception types you can handle; use domain exceptions instead of Exception/StandardError.