Skip to content

Commit

Permalink
qa: Exceptions should be either logged or rethrown but not both
Browse files Browse the repository at this point in the history
  • Loading branch information
groldan committed Dec 7, 2023
1 parent 14804e4 commit 613b278
Showing 1 changed file with 6 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import org.geoserver.catalog.Catalog;
import org.geoserver.catalog.CatalogCapabilities;
import org.geoserver.catalog.CatalogException;
import org.geoserver.catalog.CatalogFacade;
import org.geoserver.catalog.CatalogInfo;
import org.geoserver.catalog.DataStoreInfo;
Expand All @@ -24,7 +25,6 @@
import org.geoserver.catalog.impl.ProxyUtils;
import org.geotools.api.filter.Filter;
import org.geotools.api.filter.sort.SortBy;
import org.geotools.util.logging.Logging;
import org.springframework.util.Assert;

import java.lang.reflect.Proxy;
Expand All @@ -34,15 +34,11 @@
import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Supplier;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Stream;

public class RepositoryCatalogFacadeImpl extends CatalogInfoRepositoryHolderImpl
implements RepositoryCatalogFacade {

private static final Logger LOGGER = Logging.getLogger(RepositoryCatalogFacadeImpl.class);

protected Catalog catalog;

protected final CatalogCapabilities capabilities = new CatalogCapabilities();
Expand Down Expand Up @@ -586,13 +582,10 @@ public <T extends CatalogInfo> int count(final Class<T> of, final Filter filter)
try {
count = repository(of).count(of, filter);
} catch (RuntimeException e) {
LOGGER.log(
Level.SEVERE,
e,
() ->
"Error obtaining count of %s with filter %s"
.formatted(of.getSimpleName(), filter));
throw e;
throw new CatalogException(
"Error obtaining count of %s with filter %s"
.formatted(of.getSimpleName(), filter),
e);
}
}
return count > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) count;
Expand Down Expand Up @@ -643,8 +636,7 @@ public <T extends CatalogInfo> Stream<T> query(Query<T> query) {
checkCanSort(query);
stream = repository(query.getType()).findAll(query);
} catch (RuntimeException e) {
LOGGER.log(Level.SEVERE, e, () -> "Error obtaining stream: " + query);
throw e;
throw new CatalogException("Error obtaining stream: " + query, e);
}
}
return stream;
Expand Down

0 comments on commit 613b278

Please sign in to comment.