Throw exception from shared source in a java service

Hi,

Does any one have an idea how to throw service Exception from shared source in a java service in a catch block. When I use “throw new ServiceException” inside the catch block of shared source I am getting error like “unhandled Exception type ServiceException”.

Thanks in advance,
vinodkumar.

I assume, this shared rsource is a java method which is called from a java service. Hence you have to add the “throws ServiceException” clause to the method in the shared resource. Java services have it by default.

Hi fml2,

Thanks for the reply. Just posting a pseudo code.

main class code:

public static final void invokeFilePullImpSrv(IData pipeline)
throws ServiceException {

try
{
doCalculation() // Call method in shared resource
}
catch
{
throw new ServiceException(e);
}

shared resource code:

static class sub class
{
public void doCalculation()
{
try
{
}
catch(Exception e)
{
throw new ServiceException(e); // getting error here
}
}
}

Please let me know how can I throw exception back to main class from shared resource code so that the main class in-turn throws the service exception.

thanks,
vinodkumar.

As I said: add the throws clause to the throwing method:

public void doCalculation() throws ServiceException

This is basic java.

1 Like