xmlrpc frustration

J

Joe Van Dyk

argh

% cat server.rb
require 'xmlrpc/server'

class ClusterManager
def start_application args
p args
return "ok"
end
end

server =3D XMLRPC::Server.new 1998, `hostname`.strip
server.add_handler "ClusterManager", ClusterManager.new
server.serve


% cat test.rb
require 'xmlrpc/client'

client =3D XMLRPC::Client.new "fatire", nil, 1998

begin
puts client.call "ClusterManager.start_application", "oogie boogie woogie=
"
rescue XMLRPC::FaultException =3D> 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).
 
T

Tom Copeland

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

Hi Joe -

Hey, I'm doing some XMLRPC things at the moment too. When I run your
test server and client I get:

==============
$ ruby client.rb
client.rb:6: warning: parenthesize argument(s) for future version
ok
==============

Yours,

Tom
 
W

Warren Seltzer

There appear to be 2 separate exception mechanisms in Ruby, catch/throw and
rescue/raise/retry. Is this right?

Warren Seltzer
 
A

Alexandru Popescu

I haven't met/read about catch/throw. The begin/rescue/ensure/end is
for sure ;-).

/alex
 
E

Edward Faulkner

--x+6KMIRAuhnl3hBn
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

There appear to be 2 separate exception mechanisms in Ruby, catch/throw a= nd
rescue/raise/retry. Is this right?

Yes, but they're not used for the same thing. =20

rescue/raise is used to signal error conditions. This is analogous to
Exceptions in Java or C++.

Throw/catch is used to unwind the stack to a desired point. It's like
a labeled break. For example:

catch:)done){
loop {
do_work
if time_to_stop? throw :done
}
}

It's nice because you can break out of arbitrarily nested loops/blocks/etc.

regards,
Ed

--x+6KMIRAuhnl3hBn
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFDVXO6nhUz11p9MSARAsLzAJwODodjV7xdJofqvlK/RrB7pccXYQCeP4L6
1WBIRDLT5WVBj49i8MFnLUw=
=U9vD
-----END PGP SIGNATURE-----

--x+6KMIRAuhnl3hBn--
 
K

Kirk Haines

There appear to be 2 separate exception mechanisms in Ruby, catch/throw and
rescue/raise/retry. Is this right?

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
 
R

Robert Klemme

Edward said:
Yes, but they're not used for the same thing.

rescue/raise is used to signal error conditions. This is analogous to
Exceptions in Java or C++.

Throw/catch is used to unwind the stack to a desired point. It's like
a labeled break. For example:

catch:)done){
loop {
do_work
if time_to_stop? throw :done
}
}

You probably meant

catch:)done){
loop {
do_work
throw :done if time_to_stop?
}
}
It's nice because you can break out of arbitrarily nested
loops/blocks/etc.

Plus you can return something from the throw like this:

catch:)done){
loop {
do_work
throw :done, "result" if time_to_stop?
}
}

Kind regards

robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top