FANNG1 commented on code in PR #7626:
URL: https://github.com/apache/gravitino/pull/7626#discussion_r2196444808
##########
iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergTableOperations.java:
##########
@@ -89,13 +90,26 @@ public IcebergTableOperations(
@Timed(name = "list-table." + MetricNames.HTTP_PROCESS_DURATION, absolute =
true)
@ResponseMetered(name = "list-table", absolute = true)
public Response listTable(
- @PathParam("prefix") String prefix, @Encoded() @PathParam("namespace")
String namespace) {
+ @PathParam("prefix") String prefix, @Encoded() @PathParam("namespace")
String namespace)
+ throws Exception {
Review Comment:
For Iceberg REST server, we could leverage `IcebergExceptionMapper` to
handle exceptions, like
```java
try{
return utils.doAs(xxx)
} catch (Exception e) {
return IcebergExceptionMapper.toRESTResponse(e);
}
```
```java
public class IcebergExceptionMapper {
@Override
public Response toResponse(Exception ex) {
return toRESTResponse(ex);
}
// add a static method
public static Response toRESTResponse(Exception ex) {
int status =
EXCEPTION_ERROR_CODES.getOrDefault(
ex.getClass(), Status.INTERNAL_SERVER_ERROR.getStatusCode());
if (status == Status.INTERNAL_SERVER_ERROR.getStatusCode()) {
LOG.warn("Iceberg REST server unexpected exception:", ex);
} else {
LOG.info(
"Iceberg REST server error maybe caused by user request, response
http status: {}, exception: {}, exception message: {}",
status,
ex.getClass(),
ex.getMessage());
}
return IcebergRestUtils.errorResponse(ex, status);
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]