Loading ...
Sorry, an error occurred while loading the content.

Re: [soaplite] OO-ish Exception Handling

Expand Messages
  • Arun Kumar U
    Hi all, First of all sorry for buggin you all with all those gory details :-) After going thro the Error.pm code, I realize that none of these patches are
    Message 1 of 5 , May 8, 2001
    View Source
    • 0 Attachment
      Hi all,

      First of all sorry for buggin' you all with all those
      gory details :-)

      After going thro the Error.pm code, I realize that
      none of these patches are called for in SOAP::Lite

      The problem is with Error.pm and how it handles the
      '-value' attribute and the overloading method value()
      for '+0'. I have sent a detailed mail to Graham (Barr)
      the author of Error.pm, giving the details and a also
      a fix for this. I hope he'll incorporate that in
      Error.pm very soon. (Anyway, I yet to hear from Graham,
      I'll keep u all informed when that happens)

      If someone is interested in the patch then I can send
      you my patch against Error-0.13, off the list.

      Best Regards,
      Arun


      On Mon, 7 May 2001 u_arunkumar@... wrote:

      > Hi all,
      >
      > I am planning to implement OO-ish error handling over SOAP. (Using
      > Graham Barr's 'Error' module). I initially thought that if I simply
      > call
      >
      > throw Simple::Error("Some Exception on the Server");
      >
      > then I would get the exception reported on the client side. But when I
      > actually tried that, to my surprise I was not getting the exception
      > reported on the client. (If someone is interested in knowing why, then
      > let me know I'll explain that).
      >
      > After a quick peek into the SOAP/Lite.pm and the behaviour
      > of thrown Exceptions under a eval block, I was able to discover that
      > the SOAP/Lite.pm's handle() method was not detecting the throw() call
      > because it was coded as follows:
      >
      > die ref $@ ?
      > $@ : $@ =~ /^Can't locate object method "$method_name"/ ?
      > "Failed to locate method ($method_name) in class ($class)" :
      > SOAP::Fault->faultcode($SOAP::Constants::FAULT_SERVER)->
      > faultstring($@)
      > if ($@);
      >
      > I had to make the following changes for the exception to be detected:
      >
      > - if ($@);
      > + if ($@) or (ref($@);
      >
      > # normal result
      > - return $result unless ($@);
      > + return $result unless ($@ or ref($@));
      >
      > and also insert the following line between the last two make_fault()
      > calls
      > in the method.
      >
      > return $self->make_fault(ref($@), "$@", $@)
      > if UNIVERSAL::isa($@ => 'Error');
      >
      > The above statement would ensure that all exception classes derived
      > from 'Error' would be considered.
      >
      > (If the above description is confusing I can post the diffs against
      > SOAP-Lite-0.50)
      >
      > With this I am able to get the exception thrown to the remote end over
      > SOAP. Now I have to figure out a way to rethrow the exception at the
      > client end using the same exception class. Because on the client end
      >
      > I would receiving only a SOAP Fault and not an exception thrown from
      > that class. Once this is done then we would have a fully functional
      > OO-ish exception handling system working over SOAP.
      >
      > Paul !! if you are listening :-) kindly let me know your comments
      >
      > If you folks think that I am insane saying all this then please
      > bear with me :-)
      >
      > Also mind you I am trying to implement this over a TCP Transport and
      > both my client and server would be using SOAP::Lite. I have really not
      > considered all the other combinations SOAP::Lite can handle (and that
      > is exactly why I am posting this on the list, to get people on the
      > list to apply this to their situations ..)
      >
      > With this you can SOAPify any class that handles exceptions in a
      > OO-ish style and still have the same exception thrown/caught at the
      > remote end.
      >
      > Any hints/suggestions on how to have the client rethrow the exception
      > from the same Exception class as the server, would be most welcome.
      >
      > Best Regards,
      > Arun
      >
      > P.S: Paul !! would you be interested in incorporating this in
      > SOAP::Lite.
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.