backport: handle non-exceptions in `panic`

Phillip Davis created

i suspect, but have no evidence, that this is motivated by
EM::HttpClient

Change summary

sgx-bwmsgsv2.rb | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

Detailed changes

sgx-bwmsgsv2.rb 🔗

@@ -139,9 +139,15 @@ MMS_MIME_TYPES = [
 ]
 
 def panic(e)
-	Sentry.capture_exception(e)
-	puts "Shutting down gateway due to exception: #{e.message}"
-	puts e.backtrace
+	if e.is_a?(Exception)
+		puts "[#{Time.now.iso8601}] Shutting down gateway due to exception: #{e.message}"
+		Sentry.capture_exception(e, hint: { background: false })
+		puts e.backtrace
+	else
+		puts "[#{Time.now.iso8601}] Shutting down gateway due to non-exception:"
+		p e
+		Sentry.capture_message(e.to_s, hint: { background: false })
+	end
 	SGXbwmsgsv2.shutdown
 	puts 'Gateway has terminated.'
 	EM.stop