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

294Re: [soaplite] OO-ish Exception Handling

Expand Messages
  • Paul Kulchenko
    May 7 12:01 PM
      Hi, Arun!

      > Paul !! if you are listening :-) kindly let me know your comments

      :)) It definitely makes sense for me. That's the reason why I changed
      fault handling in last version (0.50) on server side (I think that
      now your calls could work, but little bit code on client side is also
      required). Next version should bring extended support on client side.
      What I have in mind is configurable STYLES of fault handling based on
      on_fault method. You will be able to specify how you want to handle
      errors, for example:

      die_with_Fault (and SOAP::Lite will die with SOAP::Fault on any
      die_with_string (and SOAP::Lite will die with string message)
      die_on_transport_error (exactly like now)
      return_transport_as_fault (will report transport errors like
      $soap-fault, say Server.Transport or something like this)
      something else probably, I'm working on it.

      You may always specify your own on_fault handler if you want, but
      styles will simplify fault handling in your code.

      What you suggest can be implemented right now as far as I understand
      (but I didn't try it yet for Simple::Error) with coding in on_fault
      handler. All extended information (and objects also) will be encoded
      inside fault detail element and can be recovered on client side.

      I like this idea, but I think your patch is not applicable right now,
      because of last changes in fault handling on server side.

      > If you folks think that I am insane saying all this then please
      > bear with me :-)
      The same thing is true about me :). If you think it's way to go let
      me know.

      NOTE! I'm going to Vegas on Interop conference and probably won't be
      able to answer my emails promptly, but don't worry, I'll answer all
      of them when I'll be back later this week.

      Best wishes, Paul.

      P.S. you may always override make_fault call in your SOAP server
      implementation and fix it, at least temporarely :). Best ideas will
      be incorporated in main code, absolutely! Thanks, Arun!

      --- 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.
      > To unsubscribe from this group, send an email to:
      > soaplite-unsubscribe@yahoogroups.com
      > Your use of Yahoo! Groups is subject to
      > http://docs.yahoo.com/info/terms/

      Do You Yahoo!?
      Yahoo! Auctions - buy the things you want at great prices
    • Show all 5 messages in this topic