Skip to content

Commit

Permalink
Avoid re-wrapping MetacatException in another MetacatException
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtfulCoder committed Jul 9, 2021
1 parent c300a52 commit 4a566ae
Showing 1 changed file with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import com.netflix.metacat.common.exception.MetacatNotFoundException;
import com.netflix.metacat.common.exception.MetacatNotSupportedException;
import com.netflix.metacat.common.exception.MetacatPreconditionFailedException;
import com.netflix.metacat.common.exception.MetacatUnAuthorizedException;
import com.netflix.metacat.common.exception.MetacatUserMetadataException;
import com.netflix.metacat.common.exception.MetacatTooManyRequestsException;
import com.netflix.metacat.common.server.api.ratelimiter.RateLimiter;
Expand Down Expand Up @@ -207,21 +206,16 @@ public <R> R processRequest(
final String message = String.format("%s.%s -- %s usermetadata operation failed for %s", e.getMessage(),
e.getCause() == null ? "" : e.getCause().getMessage(), resourceRequestName, name);
throw new MetacatUserMetadataException(message);
} catch (MetacatUnAuthorizedException e) {
} catch (Exception e) {
collectRequestExceptionMetrics(tags, e.getClass().getSimpleName());
final String message = String.format("%s.%s -- %s failed for %s", e.getMessage(),
e.getCause() == null ? "" : e.getCause().getMessage(), resourceRequestName, name);
log.error(message, e);
throw e;
} catch (MetacatTooManyRequestsException e) {
collectRequestExceptionMetrics(tags, e.getClass().getSimpleName());
throw e;
} catch (Exception e) {
collectRequestExceptionMetrics(tags, e.getClass().getSimpleName());
final String message = String.format("%s.%s -- %s failed for %s", e.getMessage(),
e.getCause() == null ? "" : e.getCause().getMessage(), resourceRequestName, name);
log.error(message, e);
throw new MetacatException(message, e);
if (e instanceof MetacatException) {
throw e;
} else {
throw new MetacatException(message, e);
}
} finally {
final long duration = registry.clock().wallTime() - start;
log.info("### Time taken to complete {} for {} is {} ms", resourceRequestName, name, duration);
Expand Down Expand Up @@ -272,7 +266,11 @@ public <R> R processRequest(
e.getMessage(), e.getCause() == null ? "" : e.getCause().getMessage(),
resourceRequestName);
log.error(message, e);
throw new MetacatException(message, e);
if (e instanceof MetacatException) {
throw e;
} else {
throw new MetacatException(message, e);
}
} finally {
final long duration = registry.clock().wallTime() - start;
log.info("### Time taken to complete {} is {} ms", resourceRequestName,
Expand Down

0 comments on commit 4a566ae

Please sign in to comment.