Skip to content

Commit

Permalink
Check exit code of Hippolytes-MacBook-Pro.local for failures
Browse files Browse the repository at this point in the history
  • Loading branch information
zippolyte committed Jan 28, 2020
1 parent dd05748 commit 6ba72c2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/dogapi/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,12 @@ def Dogapi.find_datadog_host
@@hostname = nil

def Dogapi.find_localhost
@@hostname ||= %x[hostname -f].strip
unless @@hostname
@@hostname = %x[hostname -f].strip
# Get status to check if the call was successful, because on windows, it doesn't seem to raise an exception
raise SystemCallError, 'Could not get hostname with `hostname -f`' unless $?.exitstatus == 0
end
rescue SystemCallError
raise $ERROR_INFO unless $ERROR_INFO.class.name == 'Errno::ENOENT'
@@hostname = Addrinfo.getaddrinfo(Socket.gethostname, nil, nil, nil, nil, Socket::AI_CANONNAME).first.canonname
end
end

0 comments on commit 6ba72c2

Please sign in to comment.