raising exceptions across DRb and XMLRPC

J

Joe Van Dyk

My architecture looks something like this. Please excuse the pitiful
ansi drawings.
(best viewed in fixed-width font)

------- -------
| GUI | | GUI |
------- -------
| |
| XMLRPC |
| |
| |
--------------------------
| NODE MANAGER |
--------------------------
| | |
| DRB |
| | |
| | |
------ ------ ------
|NODE| |NODE| |NODE|

I have GUIs that talk to a Node Manager that talks to Nodes.

Say, an error happens on a Node. How should I transmit that error
back across DRb and XMLRPC to the GUIs? Does XMLRPC do well with
exceptions? Should I come up with my own custom error-reporting
scheme?

Thanks,
Joe
------ ------ ------
 
F

Florian Groß

Joe said:
Say, an error happens on a Node. How should I transmit that error
back across DRb and XMLRPC to the GUIs? Does XMLRPC do well with
exceptions? Should I come up with my own custom error-reporting
scheme?

It is no problem with DRb as it can safely transport exceptions across
the network. No special casing is needed.

I'm not sure about XMLRPC.
 
J

James Britt

Florian said:
Joe Van Dyk wrote:
=20
=20
=20
It is no problem with DRb as it can safely transport exceptions across=20
the network. No special casing is needed.
=20
I'm not sure about XMLRPC.

Pretty sure XML-RPC has a defined means for expressing exceptions, or=20
faults:


http://www.xmlrpc.com/spec


James

--=20

http://www.ruby-doc.org - The Ruby Documentation Site
http://www.rubyxml.com - News, Articles, and Listings for Ruby & XML
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com - Playing with Better Toys
 
A

Adam Keys

Hm, now all I have to do is figure out how to send a
XMLRPC::FaultException. Anyone have any example code?

IIRC, just raise it like any old exception

def my_xmlrpc_method
raise XMLRPC::FaultException.new(1, 'You got exception')
end

The first parameter is the fault code you want to send, the second is
the fault string.

HTH,
 
E

Ezra Zygmuntowicz

This is how I am using the XMLRPC::FaultException:

class BlogAPIFault < StandardError
end

def mt_getCategoryList(blogid)
result = @client.call('mt.getCategoryList', blogid, @username,
@password)
rescue XMLRPC::FaultException
raise BlogAPIFault.new($!.faultString)
end

This prints nice errors to stdout.

HTH-
-Ezra


IIRC, just raise it like any old exception

def my_xmlrpc_method
raise XMLRPC::FaultException.new(1, 'You got exception')
end

The first parameter is the fault code you want to send, the second
is the fault string.

HTH,

-Ezra Zygmuntowicz
Yakima Herald-Republic
WebMaster
http://yakimaherald.com
509-577-7732
(e-mail address removed)
 
J

Joe Van Dyk

Pretty sure XML-RPC has a defined means for expressing exceptions, or
faults:


http://www.xmlrpc.com/spec

Yes, so it does.

My ClusterManager class needs to throw Exceptions. The ClusterManager
class doesn't really know anything about XMLRPC, as it's being wrapped
by a ClusterManagerServer class that starts the xmlrpc server and adds
a ClusterManager object to the xmlrpc server's handler.

Should the ClusterManager class throw XMLRPC excepts? Or plain Ruby ones?
 

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,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top