RxJavaAsyncUtil icon indicating copy to clipboard operation
RxJavaAsyncUtil copied to clipboard

Generic Exception types for ThrowableFuncX

Open simplysoft opened this issue 9 years ago • 2 comments

ThrowableFunc could be made generic in the Exception it throws, this would eliminate the need for broad catch(Exception e) when you are e.g only dealing with IOExceptions (ThrowableFunc & calling method throws IOException)

public interface ThrowingFunc0<R, E extends Exception> extends Function {
        R call() throws E;
}

If you think this is a good idea, we are happy to prepare a pull request

simplysoft avatar Apr 28 '16 15:04 simplysoft

We catch Throwables anyway so it doesn't really matter if it throws Exception or a subclass of exception. See Java's Callable<T> wasn't declared as generic throws.

akarnokd avatar Apr 28 '16 15:04 akarnokd

We are also using ThrowingFunc on non rxjava-async related code, so the interface throwing Exception make it is a bit verbose, same problem with Callable<T>. But I can understand if that change is outside the scope of this project

simplysoft avatar Apr 28 '16 15:04 simplysoft