From a7017d68e1fb647f60a79f1733e80facea5fae07 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Wed, 2 Feb 2011 10:04:56 +0100 Subject: httputil: nicer UI message when lacking ssl Rather than complaining about a missing use_ssl= method, if net/https fails to load we define a mock use_ssl= method that raises a runtime error making the LoadError message public. This is not the most user-friendly message (we would prefer not to expose internals), but it should be clear enough to help owners that forget to read the log find what's missing. --- lib/rbot/core/utils/httputil.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'lib/rbot') diff --git a/lib/rbot/core/utils/httputil.rb b/lib/rbot/core/utils/httputil.rb index 03671cfe..e69120be 100644 --- a/lib/rbot/core/utils/httputil.rb +++ b/lib/rbot/core/utils/httputil.rb @@ -14,8 +14,18 @@ require 'iconv' begin require 'net/https' rescue LoadError => e - error "Couldn't load 'net/https': #{e.pretty_inspect}" + error "Couldn't load 'net/https': #{e}" error "Secured HTTP connections will fail" + # give a nicer error than "undefined method `use_ssl='" + ::Net::HTTP.class_eval <<-EOC + define_method :use_ssl= do |val| + # does anybody really set it to false? + break if !val + raise _("I can't do secure HTTP, sorry (%{msg})") % { + :msg => e.message + } + end + EOC end # To handle Gzipped pages -- cgit v1.2.3