Skip to content

Commit

Permalink
Better error messges
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom-Newton committed Oct 15, 2023
1 parent 8505e93 commit 2b048ad
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions cpp/src/arrow/filesystem/azurefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ Status ValidateFilePath(const AzurePath& path) {
return Status::OK();
}

Status ErrorToStatus(const Azure::Storage::StorageException& exception,
const std::string& prefix = "") {
return Status::IOError(prefix, " Azure Error: ", exception.what());
}

template <typename ObjectResult>
std::shared_ptr<const KeyValueMetadata> GetObjectMetadata(const ObjectResult& result) {
auto md = std::make_shared<KeyValueMetadata>();
Expand Down Expand Up @@ -193,9 +198,10 @@ class ObjectInputFile final : public io::RandomAccessFile {
} catch (const Azure::Storage::StorageException& exception) {
if (exception.StatusCode == Azure::Core::Http::HttpStatusCode::NotFound) {
// Could be either container or blob not found.
return ::arrow::fs::internal::PathNotFound(path_.full_path);
return PathNotFound(path_);
}
return Status::IOError(exception.RawResponse->GetReasonPhrase());
return ErrorToStatus(
exception, "When fetching properties for '" + blob_client_->GetUrl() + "': ");
}
}

Expand Down Expand Up @@ -275,7 +281,9 @@ class ObjectInputFile final : public io::RandomAccessFile {
.Value;
return result.ContentRange.Length.Value();
} catch (const Azure::Storage::StorageException& exception) {
return Status::IOError(exception.RawResponse->GetReasonPhrase());
return ErrorToStatus(exception, "When reading from '" + blob_client_->GetUrl() +
"' at position " + std::to_string(position) +
" for " + std::to_string(nbytes) + " bytes: ");
}
}

Expand Down

0 comments on commit 2b048ad

Please sign in to comment.