diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2011-02-02 10:04:56 +0100 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2011-02-02 10:04:56 +0100 |
commit | a7017d68e1fb647f60a79f1733e80facea5fae07 (patch) | |
tree | 8e28d66edd992e0a1a9b9006b2157234b8512ac0 /lib/rbot | |
parent | 4d68eabaa8dabaecb5ea4af210acbb4d0b10249f (diff) |
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.
Diffstat (limited to 'lib/rbot')
-rw-r--r-- | lib/rbot/core/utils/httputil.rb | 12 |
1 files changed, 11 insertions, 1 deletions
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 |