Skip to content

Commit 4a566ae

Browse files
committed
Avoid re-wrapping MetacatException in another MetacatException
1 parent c300a52 commit 4a566ae

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

Diff for: metacat-main/src/main/java/com/netflix/metacat/main/api/RequestWrapper.java

+11-13
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import com.netflix.metacat.common.exception.MetacatNotFoundException;
2828
import com.netflix.metacat.common.exception.MetacatNotSupportedException;
2929
import com.netflix.metacat.common.exception.MetacatPreconditionFailedException;
30-
import com.netflix.metacat.common.exception.MetacatUnAuthorizedException;
3130
import com.netflix.metacat.common.exception.MetacatUserMetadataException;
3231
import com.netflix.metacat.common.exception.MetacatTooManyRequestsException;
3332
import com.netflix.metacat.common.server.api.ratelimiter.RateLimiter;
@@ -207,21 +206,16 @@ public <R> R processRequest(
207206
final String message = String.format("%s.%s -- %s usermetadata operation failed for %s", e.getMessage(),
208207
e.getCause() == null ? "" : e.getCause().getMessage(), resourceRequestName, name);
209208
throw new MetacatUserMetadataException(message);
210-
} catch (MetacatUnAuthorizedException e) {
209+
} catch (Exception e) {
211210
collectRequestExceptionMetrics(tags, e.getClass().getSimpleName());
212211
final String message = String.format("%s.%s -- %s failed for %s", e.getMessage(),
213212
e.getCause() == null ? "" : e.getCause().getMessage(), resourceRequestName, name);
214213
log.error(message, e);
215-
throw e;
216-
} catch (MetacatTooManyRequestsException e) {
217-
collectRequestExceptionMetrics(tags, e.getClass().getSimpleName());
218-
throw e;
219-
} catch (Exception e) {
220-
collectRequestExceptionMetrics(tags, e.getClass().getSimpleName());
221-
final String message = String.format("%s.%s -- %s failed for %s", e.getMessage(),
222-
e.getCause() == null ? "" : e.getCause().getMessage(), resourceRequestName, name);
223-
log.error(message, e);
224-
throw new MetacatException(message, e);
214+
if (e instanceof MetacatException) {
215+
throw e;
216+
} else {
217+
throw new MetacatException(message, e);
218+
}
225219
} finally {
226220
final long duration = registry.clock().wallTime() - start;
227221
log.info("### Time taken to complete {} for {} is {} ms", resourceRequestName, name, duration);
@@ -272,7 +266,11 @@ public <R> R processRequest(
272266
e.getMessage(), e.getCause() == null ? "" : e.getCause().getMessage(),
273267
resourceRequestName);
274268
log.error(message, e);
275-
throw new MetacatException(message, e);
269+
if (e instanceof MetacatException) {
270+
throw e;
271+
} else {
272+
throw new MetacatException(message, e);
273+
}
276274
} finally {
277275
final long duration = registry.clock().wallTime() - start;
278276
log.info("### Time taken to complete {} is {} ms", resourceRequestName,

0 commit comments

Comments
 (0)