diff --git a/cpp/src/arrow/filesystem/azurefs.cc b/cpp/src/arrow/filesystem/azurefs.cc index 6e5c2940360cf..abb0d8ad69048 100644 --- a/cpp/src/arrow/filesystem/azurefs.cc +++ b/cpp/src/arrow/filesystem/azurefs.cc @@ -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 std::shared_ptr GetObjectMetadata(const ObjectResult& result) { auto md = std::make_shared(); @@ -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() + "': "); } } @@ -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: "); } }