Creates new TracException
the error message, possibly mulit-line
host on which we are connecting to Trac
port we’re using
the path to the Trac API
the XML RPC method being called
the args (as an array) that were sent with the call
the exception that was caught
# 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
Gives a more useful message for common problems
# File lib/trac4r/error.rb, line 36 def message 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
Generated with the Darkfish Rdoc Generator 2.