throw exception Azure::Core::RequestFailedException or those inherit from that (#1463)
* throw exception Azure::Core::RequestFailedException or those inherits from that * changelog
This commit is contained in:
parent
a3a4709ba9
commit
3522c4967f
@ -15,6 +15,7 @@
|
||||
- Type for lease duration in requests was changed to `std::chrono::seconds`, in response was changed to enum.
|
||||
- `PublicAccessType::Private` was renamed to `PublicAccessType::None`.
|
||||
- `startsOn` parameter for `GetUserDelegationKey` was changed to optional.
|
||||
- Removed `IfUnmodifiedSince` from `SetBlobContainerMetadataOptions`.
|
||||
- Return types of `BlobClient::StartCopyFromUri` and `PageBlobClient::StartCopyIncremental` were changed to `StartCopyBlobResult`, supporting poll operations.
|
||||
|
||||
## 12.0.0-beta.6 (2020-01-14)
|
||||
|
||||
@ -374,7 +374,14 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
/**
|
||||
* @brief Optional conditions that must be met to perform this operation.
|
||||
*/
|
||||
BlobContainerAccessConditions AccessConditions;
|
||||
struct : public LeaseAccessConditions
|
||||
{
|
||||
/**
|
||||
* @brief Specify this header to perform the operation only if the resource has been
|
||||
* modified since the specified time. This timestamp will be truncated to second.
|
||||
*/
|
||||
Azure::Core::Nullable<Azure::Core::DateTime> IfModifiedSince;
|
||||
} AccessConditions;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -262,7 +262,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
|
||||
if (static_cast<std::size_t>(blobRangeSize) > bufferSize)
|
||||
{
|
||||
throw std::runtime_error(
|
||||
throw Azure::Core::RequestFailedException(
|
||||
"buffer is not big enough, blob range size is " + std::to_string(blobRangeSize));
|
||||
}
|
||||
|
||||
@ -270,7 +270,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
firstChunkOptions.Context, *(firstChunk->BodyStream), buffer, firstChunkLength);
|
||||
if (bytesRead != firstChunkLength)
|
||||
{
|
||||
throw std::runtime_error("error when reading body stream");
|
||||
throw Azure::Core::RequestFailedException("error when reading body stream");
|
||||
}
|
||||
firstChunk->BodyStream.reset();
|
||||
|
||||
@ -308,7 +308,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
chunkOptions.Range.GetValue().Length.GetValue());
|
||||
if (bytesRead != chunkOptions.Range.GetValue().Length.GetValue())
|
||||
{
|
||||
throw std::runtime_error("error when reading body stream");
|
||||
throw Azure::Core::RequestFailedException("error when reading body stream");
|
||||
}
|
||||
|
||||
if (chunkId == numChunks - 1)
|
||||
@ -402,7 +402,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
= Azure::Core::Http::BodyStream::ReadToCount(context, stream, buffer.data(), readSize);
|
||||
if (bytesRead != readSize)
|
||||
{
|
||||
throw std::runtime_error("error when reading body stream");
|
||||
throw Azure::Core::RequestFailedException("error when reading body stream");
|
||||
}
|
||||
fileWriter.Write(buffer.data(), bytesRead, offset);
|
||||
length -= bytesRead;
|
||||
|
||||
@ -223,12 +223,6 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
protocolLayerOptions.Metadata = metadata;
|
||||
protocolLayerOptions.LeaseId = options.AccessConditions.LeaseId;
|
||||
protocolLayerOptions.IfModifiedSince = options.AccessConditions.IfModifiedSince;
|
||||
if (options.AccessConditions.IfUnmodifiedSince.HasValue())
|
||||
{
|
||||
// Strangely enough, this operation doesn't support If-Unmodified-Since while it does support
|
||||
// If-Modified-Since
|
||||
throw std::runtime_error("this operation doesn't support unmodified since access condition.");
|
||||
}
|
||||
return Details::BlobRestClient::BlobContainer::SetMetadata(
|
||||
options.Context, *m_pipeline, m_blobContainerUrl, protocolLayerOptions);
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ namespace Azure { namespace Storage { namespace Sas {
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("unknown BlobSasResource value");
|
||||
throw std::invalid_argument("unknown BlobSasResource value");
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@ -8,13 +8,14 @@
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include <azure/core/exception.hpp>
|
||||
#include <azure/core/http/http.hpp>
|
||||
|
||||
namespace Azure { namespace Storage {
|
||||
|
||||
struct StorageException : public std::runtime_error
|
||||
struct StorageException : public Azure::Core::RequestFailedException
|
||||
{
|
||||
explicit StorageException(const std::string& message) : std::runtime_error(message) {}
|
||||
explicit StorageException(const std::string& message) : RequestFailedException(message) {}
|
||||
|
||||
Azure::Core::Http::HttpStatusCode StatusCode = Azure::Core::Http::HttpStatusCode::None;
|
||||
std::string ReasonPhrase;
|
||||
|
||||
@ -300,7 +300,10 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
|
||||
Blobs::SetBlobContainerMetadataOptions blobOptions;
|
||||
blobOptions.Context = options.Context;
|
||||
blobOptions.AccessConditions.IfModifiedSince = options.AccessConditions.IfModifiedSince;
|
||||
blobOptions.AccessConditions.IfUnmodifiedSince = options.AccessConditions.IfUnmodifiedSince;
|
||||
if (options.AccessConditions.IfUnmodifiedSince.HasValue())
|
||||
{
|
||||
std::abort();
|
||||
}
|
||||
auto result = m_blobContainerClient.SetMetadata(std::move(metadata), blobOptions);
|
||||
Models::SetDataLakeFileSystemMetadataResult ret;
|
||||
ret.ETag = std::move(result->ETag);
|
||||
|
||||
@ -416,7 +416,8 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
|
||||
ret.LastModified = std::move(result->LastModified);
|
||||
if (!acl.HasValue())
|
||||
{
|
||||
throw std::runtime_error("Got null value returned when getting access control.");
|
||||
throw Azure::Core::RequestFailedException(
|
||||
"Got null value returned when getting access control.");
|
||||
}
|
||||
ret.Acls = std::move(acl.GetValue());
|
||||
if (result->Owner.HasValue())
|
||||
|
||||
@ -24,7 +24,7 @@ namespace Azure { namespace Storage { namespace Sas {
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("unknown DataLakeSasResource value");
|
||||
throw std::invalid_argument("unknown DataLakeSasResource value");
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@ -289,7 +289,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
|
||||
auto newResponse = Download(newOptions);
|
||||
if (eTag != newResponse->ETag)
|
||||
{
|
||||
throw std::runtime_error("File was changed during the download process.");
|
||||
throw Azure::Core::RequestFailedException(
|
||||
"File was changed during the download process.");
|
||||
}
|
||||
return std::move(Download(newOptions)->BodyStream);
|
||||
};
|
||||
@ -619,7 +620,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
|
||||
|
||||
if (static_cast<std::size_t>(fileRangeSize) > bufferSize)
|
||||
{
|
||||
throw std::runtime_error(
|
||||
throw Azure::Core::RequestFailedException(
|
||||
"buffer is not big enough, file range size is " + std::to_string(fileRangeSize));
|
||||
}
|
||||
|
||||
@ -627,7 +628,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
|
||||
firstChunkOptions.Context, *(firstChunk->BodyStream), buffer, firstChunkLength);
|
||||
if (bytesRead != firstChunkLength)
|
||||
{
|
||||
throw std::runtime_error("error when reading body stream");
|
||||
throw Azure::Core::RequestFailedException("error when reading body stream");
|
||||
}
|
||||
firstChunk->BodyStream.reset();
|
||||
|
||||
@ -660,7 +661,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
|
||||
chunkOptions.Range.GetValue().Length.GetValue());
|
||||
if (bytesRead != chunkOptions.Range.GetValue().Length.GetValue())
|
||||
{
|
||||
throw std::runtime_error("error when reading body stream");
|
||||
throw Azure::Core::RequestFailedException("error when reading body stream");
|
||||
}
|
||||
|
||||
if (chunkId == numChunks - 1)
|
||||
@ -752,7 +753,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
|
||||
= Azure::Core::Http::BodyStream::ReadToCount(context, stream, buffer.data(), readSize);
|
||||
if (bytesRead != readSize)
|
||||
{
|
||||
throw std::runtime_error("error when reading body stream");
|
||||
throw Azure::Core::RequestFailedException("error when reading body stream");
|
||||
}
|
||||
fileWriter.Write(buffer.data(), bytesRead, offset);
|
||||
length -= bytesRead;
|
||||
|
||||
@ -21,7 +21,7 @@ namespace Azure { namespace Storage { namespace Sas {
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("unknown ShareSasResource value");
|
||||
throw std::invalid_argument("unknown ShareSasResource value");
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
Loading…
Reference in New Issue
Block a user