class FailableCache<K, V> {

    private final ConcurrentHashMap<K, Object> cache = new ConcurrentHashMap<>();

    protected abstract V create(K key, Errors errors) throws ErrorsException;

    public V get(K key, Errors errors) throws ErrorsException {<FILL_FUNCTION_BODY>}


    private Object load(K key) {
        Errors errors = new Errors();
        V result = null;
        try {
            result = create(key, errors);
        } catch (ErrorsException e) {
            errors.merge(e.getErrors());
        }
        return errors.hasErrors() ? errors : result;
    }
}

        Object resultOrError = cache.get(key);
        if (resultOrError == null) {
            synchronized (this) {
                resultOrError = load(key);
                // we can't use cache.computeIfAbsent since this might be recursively call this API
                cache.putIfAbsent(key, resultOrError);
            }
        }
        if (resultOrError instanceof Errors) {
            errors.merge((Errors) resultOrError);
            throw errors.toException();
        } else {
            @SuppressWarnings("unchecked") // create returned a non-error result, so this is safe
            V result = (V) resultOrError;
            return result;
        }
    
<no_super_class>