Announcement Announcement Module
Collapse
No announcement yet.
Fault Resolver for Throwable's? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Fault Resolver for Throwable's?

    I use the
    Code:
    SoapFaultAnnotationExceptionResolver.setDefaultFault()
    method to ensure that any uncaught exceptions in my web service get mapped to a SOAP Fault rather than some grungy stack trace.

    However this only appears to work for Exceptions, and not Throwable's in general; e.g. if an assertion fails then the java.lang.AssertionError gets plastered all over my web service client.

    Is there any way to head off all Throwable's short of putting catch statements in my endpoints (which kind of defeats the purpose of that setDefaultFault() stuff)?

  • #2
    Catching Throwables implies catching Errors in addition to Exceptions, which is considered to be a bad practice as Errors usually indicate a fatal situation (i.e. out of memory or the like) that you don't want to communicate to the client.
    I think that you're using assertions as mean to validate input, which is not what they are intended to do. I suggest replacing your assertions with exceptions and to map those to SOAP faults instead.

    Comment


    • #3
      Originally posted by tareq View Post
      Catching Throwables implies catching Errors in addition to Exceptions, which is considered to be a bad practice as Errors usually indicate a fatal situation (i.e. out of memory or the like) that you don't want to communicate to the client.
      I think that you're using assertions as mean to validate input, which is not what they are intended to do. I suggest replacing your assertions with exceptions and to map those to SOAP faults instead.
      Thanks for your reply Tareq; I'm using assertions to capture logical errors within my code (i.e. "this should just never happen" things) rather than validating inputs; for the latter I throw exceptions and map them to specific SOAP Faults.

      All of which seems a perfectly valid approach, but short of politely requesting the ability to catch throwables in future versions of Spring-WS, I guess there's not much to be done about it for now.

      Comment

      Working...
      X