I have situation that Activity calls Manager class that calls provider.
Activity -> Manager (method with asyncTask) -> Provider
On provider I throw custom exception
try {
// here is code that may be exception
} catch (LoadingException e) {
DataNotAvailableException ex = new DataNotAvailableException();
ex.initCause(e);
throw ex;
}
I handle this exception on my Manager class
try {
//calling provider and catching exception
} catch (DataNotAvailableException e) {
//TODO rethrow exception to activity
}
But main is problem that I can't throw exception back to the Activity that handles UI. There I want to show message (dialog) to the user, that connection unavailable.
If I try to rethrow exception it gives me error (saying surround try/catch block).
How should I send caught exception back to the activity?