Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java
Original file line number Diff line number Diff line change
Expand Up @@ -1058,12 +1058,22 @@ public List<TableIdentifier> listViews(SessionContext context, Namespace namespa
public View loadView(SessionContext context, TableIdentifier identifier) {
checkViewIdentifierIsValid(identifier);

LoadViewResponse response =
client.get(
paths.view(identifier),
LoadViewResponse.class,
headers(context),
ErrorHandlers.viewErrorHandler());
LoadViewResponse response;
try {
response =
client.get(
paths.view(identifier),
LoadViewResponse.class,
headers(context),
ErrorHandlers.viewErrorHandler());
} catch (UnsupportedOperationException | RESTException e) {
// Normally, copying an exception message is a bad practice but engines may show just the
// message and suppress the exception cause when the view does not exist. Since 401 and 403
// responses can trigger this case, including the message increases the chances that the "Not
// authorized" or "Forbidden" message is preserved and shown.
throw new NoSuchViewException(
e, "Unable to load view %s.%s: %s", name(), identifier, e.getMessage());
}

AuthSession session = tableSession(response.config(), session(context));
ViewMetadata metadata = response.metadata();
Expand Down