This should be

    $LOG.error "#{e}" if $LOG.error?
    $LOG.error "#{e.backtrace}" if $LOG.error?

Like in other rescue statements in the code.