Module: Strata::CLI::API::ConnectionErrorHandler
- Included in:
- Client, Generators::Project
- Defined in:
- lib/strata/cli/api/connection_error_handler.rb
Overview
Handles connection errors and provides user-friendly error messages
Instance Method Summary collapse
Instance Method Details
#with_connection_error_handling(server_url) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/strata/cli/api/connection_error_handler.rb', line 10 def with_connection_error_handling(server_url) yield rescue Faraday::ConnectionFailed => e handle_connection_error(server_url, e) rescue Faraday::TimeoutError => e handle_connection_error(server_url, e, timeout: true) rescue Faraday::Error => e # Check if it's a connection-related error if e..include?("Connection refused") || e..include?("Failed to open TCP connection") || e..include?("getaddrinfo") || e..include?("No route to host") handle_connection_error(server_url, e) else raise Strata::CommandError, "Network error: #{e.}" end rescue Errno::ECONNREFUSED, Errno::ETIMEDOUT, Errno::EHOSTUNREACH => e handle_connection_error(server_url, e) end |