Showing content from http://cloud.google.com/cpp/docs/reference/storage/2.30.0/storage-error below:
C++ Client Libraries | Google Cloud
Skip to main content
- Overview
-
Library reference docs
- Google Cloud Storage C++ Client Library
-
Namespaces
-
google::cloud::storage
- Overview
-
Classes
-
Functions
- PublicAccessPreventionEnforced()
- PublicAccessPreventionInherited()
- PublicAccessPreventionUnspecified()
- TEAM_EDITORS()
- TEAM_OWNERS()
- TEAM_VIEWERS()
- AutoFinalizeEnabled()
- AutoFinalizeDisabled()
- RpoDefault()
- RpoAsyncTurbo()
- CreateRandomPrefixName(std::string const &)
- DeleteByPrefix(Client &, std::string const &, std::string const &, Options &&...)
- ComposeMany(Client &, std::string const &, std::vector< ComposeSourceObject >, std::string const &, std::string, bool, Options &&...)
- MakeGrpcClient(Options)
- ComputeMD5Hash(absl::string_view)
- ComputeMD5Hash(std::string const &)
- ComputeMD5Hash(char const *)
- EnableMD5Hash()
- ComputeCrc32cChecksum(absl::string_view)
- ComputeCrc32cChecksum(std::string const &)
- ComputeCrc32cChecksum(char const *)
- ObjectRetentionUnlocked()
- ObjectRetentionLocked()
- ParallelUploadFile(Client, std::string, std::string, std::string, std::string, bool, Options &&...)
- FormatDateForForm(PolicyDocumentV4Result const &)
- AddExtensionHeader(std::string, std::string)
- WithGeneration(std::uint64_t)
- WithGenerationMarker(std::uint64_t)
- WithUserProject(std::string)
- WithMarker(std::string)
- WithResponseContentDisposition(std::string)
- WithResponseContentType(std::string const &)
- WithAcl()
- WithBilling()
- WithCompose()
- WithCors()
- WithEncryption()
- WithEncryptionConfig()
- WithLifecycle()
- WithLocation()
- WithLogging()
- WithStorageClass()
- WithTagging()
- AddExtensionField(std::string, std::string)
- RestoreResumableUploadSession(std::string)
- NewResumableUploadSession()
- version_major()
- version_minor()
- version_patch()
- version_pre_release()
- version()
- version_string()
- x_goog_api_client()
- EncryptionDataFromBinaryKey(std::string const &)
- EncryptionDataFromBase64Key(std::string const &)
- CreateKeyFromGenerator(Generator &)
- AcceptEncodingGzip()
- AcceptEncodingIdentity()
-
Operators
- operator==(CorsEntry const &, CorsEntry const &)
- operator<(CorsEntry const &, CorsEntry const &)
- operator!=(CorsEntry const &, CorsEntry const &)
- operator>(CorsEntry const &, CorsEntry const &)
- operator<=(CorsEntry const &, CorsEntry const &)
- operator>=(CorsEntry const &, CorsEntry const &)
- operator==(BucketCustomPlacementConfig const &, BucketCustomPlacementConfig const &)
- operator<(BucketCustomPlacementConfig const &, BucketCustomPlacementConfig const &)
- operator!=(BucketCustomPlacementConfig const &, BucketCustomPlacementConfig const &)
- operator>(BucketCustomPlacementConfig const &, BucketCustomPlacementConfig const &)
- operator<=(BucketCustomPlacementConfig const &, BucketCustomPlacementConfig const &)
- operator>=(BucketCustomPlacementConfig const &, BucketCustomPlacementConfig const &)
- operator==(UniformBucketLevelAccess const &, UniformBucketLevelAccess const &)
- operator<(UniformBucketLevelAccess const &, UniformBucketLevelAccess const &)
- operator!=(UniformBucketLevelAccess const &, UniformBucketLevelAccess const &)
- operator>(UniformBucketLevelAccess const &, UniformBucketLevelAccess const &)
- operator<=(UniformBucketLevelAccess const &, UniformBucketLevelAccess const &)
- operator>=(UniformBucketLevelAccess const &, UniformBucketLevelAccess const &)
- operator==(BucketIamConfiguration const &, BucketIamConfiguration const &)
- operator<(BucketIamConfiguration const &, BucketIamConfiguration const &)
- operator!=(BucketIamConfiguration const &, BucketIamConfiguration const &)
- operator>(BucketIamConfiguration const &, BucketIamConfiguration const &)
- operator<=(BucketIamConfiguration const &, BucketIamConfiguration const &)
- operator>=(BucketIamConfiguration const &, BucketIamConfiguration const &)
- operator==(BucketLifecycle const &, BucketLifecycle const &)
- operator<(BucketLifecycle const &, BucketLifecycle const &)
- operator!=(BucketLifecycle const &, BucketLifecycle const &)
- operator>(BucketLifecycle const &, BucketLifecycle const &)
- operator<=(BucketLifecycle const &, BucketLifecycle const &)
- operator>=(BucketLifecycle const &, BucketLifecycle const &)
- operator<<(std::ostream &, AutoFinalize const &)
- operator<<(std::ostream &, BucketAccessControl const &)
- operator==(BucketAutoclass const &, BucketAutoclass const &)
- operator!=(BucketAutoclass const &, BucketAutoclass const &)
- operator<<(std::ostream &, BucketAutoclass const &)
- operator==(BucketBilling const &, BucketBilling const &)
- operator<(BucketBilling const &, BucketBilling const &)
- operator!=(BucketBilling const &, BucketBilling const &)
- operator>(BucketBilling const &, BucketBilling const &)
- operator<=(BucketBilling const &, BucketBilling const &)
- operator>=(BucketBilling const &, BucketBilling const &)
- operator<<(std::ostream &, CorsEntry const &)
- operator<<(std::ostream &, BucketCustomPlacementConfig const &)
- operator==(BucketEncryption const &, BucketEncryption const &)
- operator<(BucketEncryption const &, BucketEncryption const &)
- operator!=(BucketEncryption const &, BucketEncryption const &)
- operator>(BucketEncryption const &, BucketEncryption const &)
- operator<=(BucketEncryption const &, BucketEncryption const &)
- operator>=(BucketEncryption const &, BucketEncryption const &)
- operator==(BucketHierarchicalNamespace const &, BucketHierarchicalNamespace const &)
- operator!=(BucketHierarchicalNamespace const &, BucketHierarchicalNamespace const &)
- operator<<(std::ostream &, BucketHierarchicalNamespace const &)
- operator<<(std::ostream &, UniformBucketLevelAccess const &)
- operator<<(std::ostream &, BucketIamConfiguration const &)
- operator==(BucketLogging const &, BucketLogging const &)
- operator<(BucketLogging const &, BucketLogging const &)
- operator!=(BucketLogging const &, BucketLogging const &)
- operator>(BucketLogging const &, BucketLogging const &)
- operator<=(BucketLogging const &, BucketLogging const &)
- operator>=(BucketLogging const &, BucketLogging const &)
- operator<<(std::ostream &, BucketLogging const &)
- operator<<(std::ostream &, BucketMetadata const &)
- operator==(BucketObjectRetention const &, BucketObjectRetention const &)
- operator!=(BucketObjectRetention const &, BucketObjectRetention const &)
- operator<<(std::ostream &, BucketObjectRetention const &)
- operator==(BucketRetentionPolicy const &, BucketRetentionPolicy const &)
- operator<(BucketRetentionPolicy const &, BucketRetentionPolicy const &)
- operator!=(BucketRetentionPolicy const &, BucketRetentionPolicy const &)
- operator>(BucketRetentionPolicy const &, BucketRetentionPolicy const &)
- operator<=(BucketRetentionPolicy const &, BucketRetentionPolicy const &)
- operator>=(BucketRetentionPolicy const &, BucketRetentionPolicy const &)
- operator<<(std::ostream &, BucketRetentionPolicy const &)
- operator==(BucketSoftDeletePolicy const &, BucketSoftDeletePolicy const &)
- operator!=(BucketSoftDeletePolicy const &, BucketSoftDeletePolicy const &)
- operator<<(std::ostream &, BucketSoftDeletePolicy const &)
- operator==(BucketVersioning const &, BucketVersioning const &)
- operator<(BucketVersioning const &, BucketVersioning const &)
- operator!=(BucketVersioning const &, BucketVersioning const &)
- operator>(BucketVersioning const &, BucketVersioning const &)
- operator<=(BucketVersioning const &, BucketVersioning const &)
- operator>=(BucketVersioning const &, BucketVersioning const &)
- operator==(BucketWebsite const &, BucketWebsite const &)
- operator<(BucketWebsite const &, BucketWebsite const &)
- operator!=(BucketWebsite const &, BucketWebsite const &)
- operator>(BucketWebsite const &, BucketWebsite const &)
- operator<=(BucketWebsite const &, BucketWebsite const &)
- operator>=(BucketWebsite const &, BucketWebsite const &)
- operator<<(std::ostream &, ReadRangeData const &)
- operator==(HmacKeyMetadata const &, HmacKeyMetadata const &)
- operator!=(HmacKeyMetadata const &, HmacKeyMetadata const &)
- operator<<(std::ostream &, HmacKeyMetadata const &)
- operator<<(std::ostream &, NativeExpression const &)
- operator<<(std::ostream &, NativeIamBinding const &)
- operator<<(std::ostream &, NativeIamPolicy const &)
- operator==(LifecycleRuleAction const &, LifecycleRuleAction const &)
- operator<(LifecycleRuleAction const &, LifecycleRuleAction const &)
- operator!=(LifecycleRuleAction const &, LifecycleRuleAction const &)
- operator>(LifecycleRuleAction const &, LifecycleRuleAction const &)
- operator<=(LifecycleRuleAction const &, LifecycleRuleAction const &)
- operator>=(LifecycleRuleAction const &, LifecycleRuleAction const &)
- operator<<(std::ostream &, LifecycleRuleAction const &)
- operator==(LifecycleRuleCondition const &, LifecycleRuleCondition const &)
- operator<(LifecycleRuleCondition const &, LifecycleRuleCondition const &)
- operator!=(LifecycleRuleCondition const &, LifecycleRuleCondition const &)
- operator>(LifecycleRuleCondition const &, LifecycleRuleCondition const &)
- operator<=(LifecycleRuleCondition const &, LifecycleRuleCondition const &)
- operator>=(LifecycleRuleCondition const &, LifecycleRuleCondition const &)
- operator<<(std::ostream &, LifecycleRuleCondition const &)
- operator==(LifecycleRule const &, LifecycleRule const &)
- operator<(LifecycleRule const &, LifecycleRule const &)
- operator!=(LifecycleRule const &, LifecycleRule const &)
- operator>(LifecycleRule const &, LifecycleRule const &)
- operator<=(LifecycleRule const &, LifecycleRule const &)
- operator>=(LifecycleRule const &, LifecycleRule const &)
- operator<<(std::ostream &, LifecycleRule const &)
- operator==(NotificationMetadata const &, NotificationMetadata const &)
- operator<(NotificationMetadata const &, NotificationMetadata const &)
- operator!=(NotificationMetadata const &, NotificationMetadata const &)
- operator>(NotificationMetadata const &, NotificationMetadata const &)
- operator<=(NotificationMetadata const &, NotificationMetadata const &)
- operator>=(NotificationMetadata const &, NotificationMetadata const &)
- operator<<(std::ostream &, NotificationMetadata const &)
- operator<<(std::ostream &, ObjectAccessControl const &)
- operator<<(std::ostream &, ComposeSourceObject const &)
- operator==(CustomerEncryption const &, CustomerEncryption const &)
- operator<(CustomerEncryption const &, CustomerEncryption const &)
- operator!=(CustomerEncryption const &, CustomerEncryption const &)
- operator>(CustomerEncryption const &, CustomerEncryption const &)
- operator<=(CustomerEncryption const &, CustomerEncryption const &)
- operator>=(CustomerEncryption const &, CustomerEncryption const &)
- operator<<(std::ostream &, ObjectMetadata const &)
- operator==(ObjectRetention const &, ObjectRetention const &)
- operator!=(ObjectRetention const &, ObjectRetention const &)
- operator<<(std::ostream &, ObjectRetention const &)
- operator==(Owner const &, Owner const &)
- operator<(Owner const &, Owner const &)
- operator!=(Owner const &, Owner const &)
- operator>(Owner const &, Owner const &)
- operator<=(Owner const &, Owner const &)
- operator>=(Owner const &, Owner const &)
- operator==(PolicyDocumentCondition const &, PolicyDocumentCondition const &)
- operator<(PolicyDocumentCondition const &, PolicyDocumentCondition const &)
- operator!=(PolicyDocumentCondition const &, PolicyDocumentCondition const &)
- operator>(PolicyDocumentCondition const &, PolicyDocumentCondition const &)
- operator<=(PolicyDocumentCondition const &, PolicyDocumentCondition const &)
- operator>=(PolicyDocumentCondition const &, PolicyDocumentCondition const &)
- operator<<(std::ostream &, PolicyDocumentCondition const &)
- operator<<(std::ostream &, PolicyDocument const &)
- operator<<(std::ostream &, PolicyDocumentV4 const &)
- operator<<(std::ostream &, PolicyDocumentResult const &)
- operator<<(std::ostream &, PolicyDocumentV4Result const &)
- operator==(ProjectTeam const &, ProjectTeam const &)
- operator<(ProjectTeam const &, ProjectTeam const &)
- operator!=(ProjectTeam const &, ProjectTeam const &)
- operator>(ProjectTeam const &, ProjectTeam const &)
- operator<=(ProjectTeam const &, ProjectTeam const &)
- operator>=(ProjectTeam const &, ProjectTeam const &)
- operator==(ServiceAccount const &, ServiceAccount const &)
- operator<(ServiceAccount const &, ServiceAccount const &)
- operator!=(ServiceAccount const &, ServiceAccount const &)
- operator>(ServiceAccount const &, ServiceAccount const &)
- operator<=(ServiceAccount const &, ServiceAccount const &)
- operator>=(ServiceAccount const &, ServiceAccount const &)
- operator<<(std::ostream &, ServiceAccount const &)
- operator<<(std::ostream &, CustomHeader const &)
- operator<<(std::ostream &, EncryptionKey const &)
- operator<<(std::ostream &, SourceEncryptionKey const &)
-
google::cloud::storage::event_type
-
google::cloud::storage::oauth2
- Overview
-
Classes
-
AuthorizedUserCredentials<HttpRequestBuilderType, ClockType>
-
ComputeEngineCredentials<HttpRequestBuilderType, ClockType>
-
ServiceAccountCredentials<HttpRequestBuilderType, ClockType>
-
Functions
- CreateAnonymousCredentials()
- CreateAuthorizedUserCredentialsFromJsonFilePath(std::string const &)
- CreateAuthorizedUserCredentialsFromJsonContents(std::string const &, ChannelOptions const &)
- CreateServiceAccountCredentialsFromFilePath(std::string const &)
- CreateServiceAccountCredentialsFromFilePath(std::string const &, absl::optional< std::set< std::string > >, absl::optional< std::string >)
- CreateServiceAccountCredentialsFromJsonFilePath(std::string const &)
- CreateServiceAccountCredentialsFromJsonFilePath(std::string const &, absl::optional< std::set< std::string > >, absl::optional< std::string >, ChannelOptions const &)
- CreateServiceAccountCredentialsFromP12FilePath(std::string const &)
- CreateServiceAccountCredentialsFromP12FilePath(std::string const &, absl::optional< std::set< std::string > >, absl::optional< std::string >, ChannelOptions const &)
- ParseAuthorizedUserRefreshResponse(storage::internal::HttpResponse const &, std::chrono::system_clock::time_point)
- ParseAuthorizedUserCredentials(std::string const &, std::string const &, std::string const &)
- ParseMetadataServerResponse(storage::internal::HttpResponse const &)
- ParseComputeEngineRefreshResponse(storage::internal::HttpResponse const &, std::chrono::system_clock::time_point)
- GoogleOAuthAccessTokenLifetime()
- GoogleOAuthAccessTokenExpirationSlack()
- GoogleOAuthRefreshEndpoint()
- GoogleOAuthScopeCloudPlatform()
- GoogleAdcEnvVar()
- GoogleAdcFilePathFromEnvVarOrEmpty()
- GoogleAdcFilePathFromWellKnownPathOrEmpty()
- GoogleGcloudAdcFileEnvVar()
- GoogleAdcHomeEnvVar()
- GoogleDefaultCredentials(ChannelOptions const &)
- CreateServiceAccountCredentialsFromDefaultPaths(ChannelOptions const &)
- CreateServiceAccountCredentialsFromDefaultPaths(absl::optional< std::set< std::string > >, absl::optional< std::string >, ChannelOptions const &)
- CreateServiceAccountCredentialsFromJsonContents(std::string const &, ChannelOptions const &)
- CreateServiceAccountCredentialsFromJsonContents(std::string const &, absl::optional< std::set< std::string > >, absl::optional< std::string >, ChannelOptions const &)
- CreateComputeEngineCredentials()
- CreateComputeEngineCredentials(std::string const &)
- ParseServiceAccountCredentials(std::string const &, std::string const &, std::string const &)
- ParseServiceAccountP12File(std::string const &, std::string const &)
- ParseServiceAccountRefreshResponse(storage::internal::HttpResponse const &, std::chrono::system_clock::time_point)
- AssertionComponentsFromInfo(ServiceAccountCredentialsInfo const &, std::chrono::system_clock::time_point)
- MakeJWTAssertion(std::string const &, std::string const &, std::string const &)
- CreateServiceAccountRefreshPayload(ServiceAccountCredentialsInfo const &, std::string const &, std::chrono::system_clock::time_point)
- MakeSelfSignedJWT(ServiceAccountCredentialsInfo const &, std::chrono::system_clock::time_point)
- ServiceAccountUseOAuth(ServiceAccountCredentialsInfo const &)
-
google::cloud::storage::payload_format
-
google::cloud::storage::storage_class
-
google::cloud::storage_experimental
- Overview
-
Classes
-
AsyncClient
- Overview
-
Functions
- InsertObject(BucketName const &, std::string, Collection &&, Options)
- InsertObject(google::storage::v2::WriteObjectRequest, Collection &&, Options)
- InsertObject(google::storage::v2::WriteObjectRequest, WritePayload, Options)
- ReadObject(BucketName const &, std::string, Options)
- ReadObject(google::storage::v2::ReadObjectRequest, Options)
- ReadObjectRange(BucketName const &, std::string, std::int64_t, std::int64_t, Options)
- ReadObjectRange(google::storage::v2::ReadObjectRequest, std::int64_t, std::int64_t, Options)
- StartBufferedUpload(BucketName const &, std::string, Options)
- StartBufferedUpload(google::storage::v2::StartResumableWriteRequest, Options)
- ResumeBufferedUpload(std::string, Options)
- ResumeBufferedUpload(google::storage::v2::QueryWriteStatusRequest, Options)
- StartUnbufferedUpload(BucketName const &, std::string, Options)
- StartUnbufferedUpload(google::storage::v2::StartResumableWriteRequest, Options)
- ResumeUnbufferedUpload(std::string, Options)
- ResumeUnbufferedUpload(google::storage::v2::QueryWriteStatusRequest, Options)
- ComposeObject(BucketName const &, std::string, std::vector< google::storage::v2::ComposeObjectRequest::SourceObject >, Options)
- ComposeObject(google::storage::v2::ComposeObjectRequest, Options)
- DeleteObject(BucketName const &, std::string, Options)
- DeleteObject(BucketName const &, std::string, std::int64_t, Options)
- DeleteObject(google::storage::v2::DeleteObjectRequest, Options)
- StartRewrite(BucketName const &, std::string, BucketName const &, std::string, Options)
- StartRewrite(google::storage::v2::RewriteObjectRequest, Options)
- ResumeRewrite(BucketName const &, std::string, BucketName const &, std::string, std::string, Options)
- ResumeRewrite(google::storage::v2::RewriteObjectRequest, Options)
Stay organized with collections Save and categorize content based on your preferences.
Error Handling
This library never throws exceptions to signal errors. In general, the library returns a StatusOr. Some functions return objects that already have an existing error handling mechanism. For example, ReadObject()
returns a type derived from std::istream
where the application can check the state flags to determine if there was an error. In these cases no StatusOr
wrapper is used.
Applications should check if the StatusOr<T>
contains a value before using it, much like how you might check that a pointer is not null before dereferencing it. Indeed, a StatusOr<T>
object can be used like a smart-pointer to T
, with the main difference being that when it does not hold a T
it will instead hold a Status
object with extra information about the error.
You can check that a StatusOr<T>
contains a value by calling the .ok()
method, or by using operator bool()
(like with other smart pointers). If there is no value, you can access the contained Status
object using the .status()
member. If there is a value, you may access it by dereferencing with operator*()
or operator->()
. As with all smart pointers, callers must first check that the StatusOr<T>
contains a value before dereferencing and accessing the contained value. Alternatively, callers may instead use the .value()
member function which is defined to throw a RuntimeStatusError if there is no value.
Error Handling Example (without exceptions)
Applications that do not use exceptions to signal errors should check if the StatusOr<T>
contains a value before using it. If the StatusOr<T>
does contain a value then the StatusOr<T>
can be used as a smart pointer to T
. That is, operator->()
and operator*()
work as you would expect. If the StatusOr<T>
does not contain a value then the error details are available using the .status()
member function (and trying to access the value produces undefined behavior).
using gcs = ::google::cloud::storage;
[](gcs::Client client) {
google::cloud::StatusOr<gcs::BucketMetadata> metadata =
client.GetBucketMetadata("my-bucket");
if (!metadata) {
std::cerr << "GetBucketMetadata: " << metadata.status() << "\n";
return;
}
// use `metadata` as a smart pointer to `BucketMetadata`
std::cout << "The metadata for bucket " << metadata->name()
<< " is " << *metadata << "\n";
}
Error Handling Example (with exceptions)
Applications that use exceptions to signal errors can simply call .value()
on the StatusOr<T>
object. This will return a T
if the StatusOr<T>
object contains a value, and will otherwise throw an exception.
using gcs = ::google::cloud::storage;
[](gcs::Client client) {
gcs::BucketMetadata metadata = client.GetBucketMetadata(
"my-bucket").value(); // throws on error
std::cout << "The metadata for bucket " << metadata.name()
<< " is " << metadata << "\n";
}
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-14 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[[["This document provides version-specific documentation for the C++ Storage library, ranging from the latest release candidate (2.37.0-rc) down to version 2.11.0, each linking to detailed error information."],["The C++ Storage library uses `StatusOr\u003cT\u003e` for error handling, avoiding exceptions to signal errors, and requiring applications to check if it holds a value before dereferencing."],["`StatusOr\u003cT\u003e` can be treated as a smart pointer to `T`, allowing the use of `operator-\u003e()` and `operator*()` when a value is present, or accessing error details via the `.status()` member if no value is present."],["When exceptions are in use, the `.value()` method can be used on the `StatusOr\u003cT\u003e` object, which will return the value if it exists, or throw a `RuntimeStatusError` if there is an error."],["There are examples of error handling both with and without exceptions in this document, showcasing how to check for values before using the smart pointer, and how to utilize the .value() method for exception based use."]]],[]]
RetroSearch is an open source project built by @garambo
| Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4