class ClusterManager
def start_application args
p args
return "ok"
end
end
server = XMLRPC::Server.new 1998, `hostname`.strip
server.add_handler "ClusterManager", ClusterManager.new
server.serve
% cat test.rb
require 'xmlrpc/client'
client = XMLRPC::Client.new "fatire", nil, 1998
begin
puts client.call "ClusterManager.start_application", "oogie boogie woogie"
rescue XMLRPC::FaultException => e
p e
p e.faultCode
p e.faultString
end
% ruby test.rb
/usr/local/lib/ruby/1.8/xmlrpc/client.rb:535:in `do_rpc': HTTP-Error:
500 Internal Server Error (RuntimeError)
from /usr/local/lib/ruby/1.8/xmlrpc/client.rb:409:in `call2'
from /usr/local/lib/ruby/1.8/xmlrpc/client.rb:399:in `call'
from test.rb:7
What's up with the 500 Internal Server Error?
(btw, "oogie boogie woogie" printed in the server output).
Hey, I'm doing some XMLRPC things at the moment too. When I run your
test server and client I get:
···
On Thu, 2005-10-06 at 06:23 +0900, Joe Van Dyk wrote:
argh
% cat server.rb
require 'xmlrpc/server'
class ClusterManager
def start_application args
p args
return "ok"
end
end
server = XMLRPC::Server.new 1998, `hostname`.strip
server.add_handler "ClusterManager", ClusterManager.new
server.serve
==============
$ ruby client.rb
client.rb:6: warning: parenthesize argument(s) for future version
ok
Yours,
Tom
% cat test.rb
require 'xmlrpc/client'
client = XMLRPC::Client.new "fatire", nil, 1998
begin
puts client.call "ClusterManager.start_application", "oogie boogie woogie"
rescue XMLRPC::FaultException => e
p e
p e.faultCode
p e.faultString
end
% ruby test.rb
/usr/local/lib/ruby/1.8/xmlrpc/client.rb:535:in `do_rpc': HTTP-Error:
500 Internal Server Error (RuntimeError)
from /usr/local/lib/ruby/1.8/xmlrpc/client.rb:409:in `call2'
from /usr/local/lib/ruby/1.8/xmlrpc/client.rb:399:in `call'
from test.rb:7
What's up with the 500 Internal Server Error?
(btw, "oogie boogie woogie" printed in the server output).
Not really. A throw just lets one unwind from some deep nesting without
generating a back trace, passing some value along to the catch.
It is much faster and lighter weight than the exception mechanism, and should
be used for cases where a fast, lightweight escape from some deep place is
wanted, perhaps with some passing of data from the deep place to the shallow
place, but where an actual exception isn't needed.
Kirk Haines
···
On Tuesday 18 October 2005 4:07 pm, Warren Seltzer wrote:
There appear to be 2 separate exception mechanisms in Ruby, catch/throw and
rescue/raise/retry. Is this right?