You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by D P <de...@gmail.com> on 2006/07/20 23:26:00 UTC

General error handling question

When an uncaught exception occurs, I would like to send a generic message
saying only that an error occurred, instead of the default behavior which
returns the exception message to the client in a soap fault.  While I do
have appropriate exception handling in my services, does axis2 have any
functionality to do this in a more centralized manner?

Re: General error handling question

Posted by D P <de...@gmail.com>.
Thank you for the feedback.  I presume you're referring to wsdl: fault
elements?  Please correct if wrong, but that would only work if the
exception was expected and caught somewhere in the service, and I'm looking
for something in axis2 which catches unhandled exceptions that get thrown up
into the axis2 stack.  The reason why I'm looking at axis2 is that it is the
single central path through which unhandled exceptions are thrown, and
trying to standardize this type of error handling at the service level would
be time consuming, difficult to standardize, and (in the example below) may
not be the best design solution.  Perhaps a code example would help:

public class FooSkeleton implements FooSkeletonInterface {

    public void init(ServiceContext serviceContext)
            throws NamingException {

        Context initalContext = new InitialContext();
        dataSource = (DataSource) initalContext
                .lookup((String) axisConfiguration.getParameter(
                        AxisServlet.JNDI_DATASOURCE_NAME ).getValue());
    }
}

Let's say there are multiple services with this kind of init() method, and
let's say a naming exception is thrown.  The services can't function without
the datasource so there isn't any action the init() method can take if the
exception occurs other than to rethrow it. Axis2 would eventually catch this
exception and format the exception message as a soap fault.  I would like to
either a) see if a mechanism already exists that allows me to configure
axis2 to send a generic fault message instead (other than just shutting off
the stack trace), or b) see if there is anything in the axis2 API that would
allow me to hook into the error handling to customize it.

Hopefully this clarifies things, please let me know.



On 7/21/06, robert lazarski < robertlazarski@gmail.com> wrote:
>
> If you're using WSDL, just define an error message as a string and
> code as an int, catch exceptions and populate the vars, conversely
> with success messages. Otherwise, not sure.
>
> HTH,
> Robert
> http://www.braziloutsource.com/
>
> On 7/20/06, D P <developerperson@gmail.com > wrote:
> > When an uncaught exception occurs, I would like to send a generic
> message
> > saying only that an error occurred, instead of the default behavior
> which
> > returns the exception message to the client in a soap fault.  While I do
> > have appropriate exception handling in my services, does axis2 have any
> > functionality to do this in a more centralized manner?
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>

Re: General error handling question

Posted by robert lazarski <ro...@gmail.com>.
If you're using WSDL, just define an error message as a string and
code as an int, catch exceptions and populate the vars, conversely
with success messages. Otherwise, not sure.

HTH,
Robert
http://www.braziloutsource.com/

On 7/20/06, D P <de...@gmail.com> wrote:
> When an uncaught exception occurs, I would like to send a generic message
> saying only that an error occurred, instead of the default behavior which
> returns the exception message to the client in a soap fault.  While I do
> have appropriate exception handling in my services, does axis2 have any
> functionality to do this in a more centralized manner?
>

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org