diqiu50 commented on code in PR #13787:
URL: https://github.com/apache/gravitino/pull/13787#discussion_r4248485108
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/CatalogConnectorMetadata.java:
##########
@@ -451,6 +483,23 @@ public Function getFunction(String schemaName, String
functionName) {
if (!supportsFunctions()) {
throw new UnsupportedOperationException("Catalog does not support
functions");
}
- return functionCatalog.getFunction(NameIdentifier.of(schemaName,
functionName));
+ try {
+ return functionCatalog.getFunction(NameIdentifier.of(schemaName,
functionName));
+ } catch (ForbiddenException | IllegalArgumentException e) {
+ throw toTrinoException(e);
+ }
+ }
+
+ /**
+ * Converts a refusal reported by the Gravitino server into a Trino
exception that classifies it
+ * as a user-facing error instead of an internal one.
+ */
+ private static TrinoException toTrinoException(RuntimeException e) {
+ String message = GravitinoErrorCode.toSimpleErrorMessage(e);
+ if (e instanceof ForbiddenException) {
+ return new TrinoException(PERMISSION_DENIED, message, e);
+ }
+ // Server-side validation failures, such as an illegal object name or a
policy refusal.
+ return new TrinoException(GravitinoErrorCode.GRAVITINO_ILLEGAL_ARGUMENT,
message, e);
Review Comment:
This is intentional: it's the code the connector already uses for illegal
arguments, and keeping it keeps the error name stable. The goal here is to stop
reporting INTERNAL_ERROR.
--
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]