Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No error code present in extended_error for 416: InvalidRange #395

Open
ajs97 opened this issue Apr 12, 2021 · 1 comment
Open

No error code present in extended_error for 416: InvalidRange #395

ajs97 opened this issue Apr 12, 2021 · 1 comment

Comments

@ajs97
Copy link

ajs97 commented Apr 12, 2021

I have added the error handling code, and this particular error does not have the error code present in the storage_exception. I added this logging:

  HandleException(const azure::storage::storage_exception& e) {
  auto result = e.result();
  int http_status_code = result.http_status_code();
  auto extended_error = result.extended_error();
  cout   << "HTTP Status Code: " << http_status_code
              << " , error_code: " << extended_error.code()
              << " , error message: " << e.what();

I don't get the error code for the InvalidRange error:

HTTP Status Code: 416 , error_code:  , error message: The range specified is invalid for the current size of the resource.

Is this expected? Is there any other error which will return status code 416, or is InvalidRange the only one that has 416?

@ljluestc
Copy link

#include <azure/storage/common/storage_common.hpp>
#include <azure/storage/blobs/blob_service_client.hpp>

void HandleException(const azure::storage::storage_exception& e) {
auto result = e.result();
int http_status_code = result.http_status_code();
auto extended_error = result.extended_error();

if (http_status_code == 416) {
    // Handle the InvalidRange error here
    std::cout << "Received InvalidRange error: " << e.what() << std::endl;
} else {
    // Handle other errors
    std::cout << "HTTP Status Code: " << http_status_code
              << " , error_code: " << extended_error.code()
              << " , error message: " << e.what() << std::endl;
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants