Exception: Trac::TracException
- Inherits:
-
Exception
- Object
- Exception
- Trac::TracException
- Defined in:
- lib/trac4r/error.rb
Instance Method Summary collapse
-
#initialize(http_error, host, port, path, method, args, exception) ⇒ TracException
constructor
Creates new TracException.
-
#message ⇒ Object
Gives a more useful message for common problems.
- #url ⇒ Object
Constructor Details
#initialize(http_error, host, port, path, method, args, exception) ⇒ TracException
Creates new TracException
http_error
-
the error message, possibly mulit-line
host
-
host on which we are connecting to Trac
port
-
port we’re using
path
-
the path to the Trac API
method
-
the XML RPC method being called
args
-
the args (as an array) that were sent with the call
exception
-
the exception that was caught
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/trac4r/error.rb', line 12 def initialize(http_error,host,port,path,method,args,exception) if (http_error =~ /HTTP-Error: /) http_error = http_error.sub 'HTTP-Error: ','' if http_error =~ /\n/ http_error.split(/\n/).each do |line| if line =~ /^\d\d\d/ http_error = line break end end end @http_status,@http_message = http_error.split(/\s+/,2) else @http_message = http_error end @host = host @port = port @path = path @method = method @args = args @exception = exception end |
Instance Method Details
#message ⇒ Object
Gives a more useful message for common problems
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/trac4r/error.rb', line 36 def if @http_status == '404' "Couldn't find Trac API at #{url}, check your configuration" elsif @http_status == '401' "Your username/password didn't authenticate, check your configuration" elsif @http_status "#{@http_message} (#{@http_status}) when trying URL #{url} and method #{@method}(#{@args.join('.')})" else "#{@http_message} when trying URL #{url} and method #{@method}(#{@args.join('.')})" end end |
#url ⇒ Object
48 49 50 |
# File 'lib/trac4r/error.rb', line 48 def url "http://#{@host}:#{@port}#{@path}" end |