1 # $Id$ |
2 |
3 # Job������������������������ |
4 class HudsonNoJobException < Exception |
5 end |
6 |
7 # ������������������������������ |
8 class HudsonNoSettingsException < Exception |
9 end |
10 |
11 class HudsonApiException < Exception |
12 attr_reader :message, :code, :inner_exception |
13 |
14 include ApplicationHelper |
15 include ActionView::Helpers::TextHelper |
16 include Redmine::I18n if RedmineHudson::RedmineExt.redmine_090_or_higher? |
17 |
18 def initialize( object ) |
19 @code = "" |
20 @message = "" |
21 @inner_exception = object |
22 |
23 case object |
24 when Net::HTTPResponse |
25 @code = object.code |
26 @message = l(:notice_err_http_error, object.code) |
27 when Net::HTTPBadResponse |
28 @message = l(:notice_err_response_invalid, "Net::HTTPBadResponse") |
29 when SocketError |
30 @message = l(:notice_err_cant_connect, object.message) |
31 when Errno::ECONNREFUSED, Errno::ETIMEDOUT |
32 @message = l(:notice_err_cant_connect, object.message) |
33 when URI::InvalidURIError |
34 @message = l(:notice_err_invalid_url) |
35 when REXML::ParseException |
36 @message = l(:notice_err_response_invalid, truncate(object.to_s, 50)) |
37 else |
38 # ruby1.8.7 returns error - "undefined method `closed?' for nil:NilClass" when can't connect server ??? |
39 if "undefined method `closed?' for nil:NilClass" == object.message |
40 @message = l(:notice_err_cant_connect, object.message) |
41 else |
42 @message = l(:notice_err_unknown, object.message) |
43 end |
44 end |
45 end |
46 end |