class ContextsManager {

    protected <T> T callAndGet(UUID contextUuid, Callable<T> callable){
        final Future<T> future = contextExecutorService.runWithContext(contextUuid, callable);
        try {
            return future.get();
        } catch (CancellationException e){
            throw new OperationCancelledException(e);
        } catch (ExecutionException e){
            final Throwable cause = e.getCause();
            if(cause instanceof RuntimeException){
                throw (RuntimeException)cause;
            } else {
                throw new JSExceptionWrapper((Exception) cause);
            }
        } catch (Exception e) {
            throw new JSExceptionWrapper(e);
        }
    }

}