begin
result = service.load_data()
rescue AnExceptionKlass => details # here the name is SocketError
logger.fatal "Failed to load the data: #{details}"
end
use the above.
tried to replicate the error here as below:
require 'net/http'
Net::HTTP.start('http://www.google.com') do |http|
response = http.get('/')
puts response
end
#=> getaddrinfo: No such host is known. (SocketError)
Fixed it as below:
require 'net/http'
begin
htt = Net::HTTP.start('http://www.google.com')
response = htt.get('/')
puts response
rescue SocketError => details # or the Exception class name may be SocketError
p "Failed to load the data: #{details}"
end
#=> "Failed to load the data: getaddrinfo: No such host is known. "