class RxWrapper {

    public T unwrap(Observable<T> observable) throws IOException {
        final Holder<T> holder = new Holder<>();
        final Throwable[] throwable = new Throwable[1];

        observable.toBlocking().subscribe(new Action1<T>() {
            @Override
            public void call(T t) {
                holder.obj = t;
            }
        }, new Action1<Throwable>() {
            @Override
            public void call(Throwable t) {
                throwable[0] = t;
            }
        });

        if(throwable[0] != null) {
            if(throwable[0] instanceof IOException) {
                throw (IOException) throwable[0];
            } else {
                throw new RuntimeException(throwable[0]);
            }
        } else {
            return holder.obj;
        }
    }

}