FIX: ThreadError Handling (#175)

FIX: ThreadError Handling (#175)

Don’t leak out an exception if the main thread is killed.

if (GET_VM()->main_thread->status == THREAD_KILLED)
rb_raise(rb_eThreadError, "can't alloc thread");

This can happen during certain application shutdowns.

diff --git a/lib/prometheus_exporter/client.rb b/lib/prometheus_exporter/client.rb
index da3f433..3b60c6d 100644
--- a/lib/prometheus_exporter/client.rb
+++ b/lib/prometheus_exporter/client.rb
@@ -184,6 +184,9 @@ module PrometheusExporter
           end
         end
       end
+    rescue ThreadError => e
+      raise unless e.message =~ /can't alloc thread/
+      STDERR.puts "Prometheus Exporter, failed to send message ThreadError #{e}"
     end
 
     def close_socket!

GitHub sha: bd961c4650270bf90fa7d3eeeb14d7103c5382fb

This commit appears in #175 which was merged by SamSaffron.