Commit da1a0289 authored by Benjamin Neff's avatar Benjamin Neff

log backtrace for unexpected errors in ConnectionTester

parent 28ca071e
class ConnectionTester
NODEINFO_SCHEMA = "http://nodeinfo.diaspora.software/ns/schema/1.0"
NODEINFO_FRAGMENT = "/.well-known/nodeinfo"
include Diaspora::Logging
NODEINFO_SCHEMA = "http://nodeinfo.diaspora.software/ns/schema/1.0".freeze
NODEINFO_FRAGMENT = "/.well-known/nodeinfo".freeze
class << self
# Test the reachability of a server by the given HTTP/S URL.
......@@ -74,7 +76,7 @@ class ConnectionTester
rescue URI::InvalidURIError => e
raise AddressFailure, e.message
rescue StandardError => e
raise Failure, e.inspect
unexpected_error(e)
end
# Perform the DNS query, the IP address will be stored in the result
......@@ -84,7 +86,7 @@ class ConnectionTester
rescue SocketError => e
raise DNSFailure, "'#{@uri.host}' - #{e.message}"
rescue StandardError => e
raise Failure, e.inspect
unexpected_error(e)
end
# Perform a HTTP GET request to determine the following information
......@@ -113,7 +115,7 @@ class ConnectionTester
rescue ArgumentError, FaradayMiddleware::RedirectLimitReached, Faraday::ClientError => e
raise HTTPFailure, e.message
rescue StandardError => e
raise Failure, e.inspect
unexpected_error(e)
end
# Try to find out the version of the other servers software.
......@@ -130,7 +132,7 @@ class ConnectionTester
rescue Faraday::ResourceNotFound, JSON::JSONError => e
raise NodeInfoFailure, e.message[0..255].encode(Encoding.default_external, undef: :replace)
rescue StandardError => e
raise Failure, e.inspect
unexpected_error(e)
end
private
......@@ -192,6 +194,11 @@ class ConnectionTester
@result.software_version = "#{sw.fetch('name')} #{sw.fetch('version')}"
end
def unexpected_error(error)
logger.error "unexpected error: #{error.class}: #{error.message}\n#{error.backtrace.first(15).join("\n")}"
raise Failure, error.inspect
end
class Failure < StandardError
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment