Results 1 to 3 of 3

Thread: Exception handling

  1. #1

    Default Exception handling

    Hi,
    I'm relatively new to both Flex and Spring MVC, so this may be a trivial question. I have created an exposed service and registered it with the Flex broker. This is working great. But I am now trying to work out how to best handle faults, and not managing to find much about it online. In certain cases I would like to throw exceptions from my service, such as in the case of failed spring security roles or illegal arguments (that may not have be possible to catch on the client, such as an invalid ID). At the moment I have a single fault handler for my RemoteObject which simply shows event.fault.faultString, i.e. the exception message.

    So my question is: How are you handling exceptions and FaultEvents within your Spring-Flex applications?

    One site I have found [1] talks about converting every exception into a FlexException (or subclass) and then parsing substrings on the fault message on the client side (that part sounds a little too brittle). Is this a good use case for a HandlerExceptionResolver? Is it possible to use that with Spring-Flex?

    Thanks,
    Martin.

    [1] http://www.flexpasta.com/index.php/2...zeds-and-flex/

  2. #2
    Join Date
    Apr 2005
    Location
    San Francisco, CA
    Posts
    1,224

    Default

    With the new M2, we do automatic interception of Spring Security exceptions at such a point where we can translate them to Flex SecurityExceptions and re-throw so that a proper AMF error message will be serialized and sent back to the client. You still handle this as a fault event, but you can at least reason on the fault code (event.fault.faultCode) which even though it is a String is at least constant and a little less brittle than parsing the fault string.

    A HandlerExceptionResolver doesn't get the job done, because at that point you're on the wrong side of the AMF serialization process. But this does raise a good point that a more general hook would be good where you could insert your own exception translation logic in addition to our provided SpringSecurityException translation. I will add a JIRA for that for RC1.
    Jeremy Grelle

    Staff Engineer, Web Products Team
    SpringSource

  3. #3

    Default

    Quote Originally Posted by jeremyg484 View Post
    A HandlerExceptionResolver doesn't get the job done, because at that point you're on the wrong side of the AMF serialization process. But this does raise a good point that a more general hook would be good where you could insert your own exception translation logic in addition to our provided SpringSecurityException translation. I will add a JIRA for that for RC1.
    Is that to say you are unable to use any handlerInterceptors? Outside of security we would quite like to log exceptions before they bubble out. Is there a generic hook before the serialisation phase?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •