azure-sdk-for-go
azure-sdk-for-go copied to clipboard
Unable to get azblob.StorageError for block blob operations
Unable to get azblob.StorageError for block blob operations
Steps to reproduce
- Download the latest versions of github.com/Azure/azure-sdk-for-go
- Run simple block blob client and try to get properties for non-existing block blob:
import "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob"
...
serviceClient, err := azblob.NewServiceClientWithSharedKey(primaryEndpoint, sharedKeyCredential, nil)
containerClient := serviceClient.NewContainerClient(containerName)
blobClient := containerClient.NewBlockBlobClient(blobName)
properties, err := blockBlob.GetProperties(ctx, nil)
log.Printf("error is %+v: %+v", reflect.TypeOf(err), err)
storageError := azblob.StorageError{}
log.Printf("error is azblob.StorageError: %+v", errors.As(err, &storageError))
Expected results
error is *azblob.StorageError: ....
error is azblob.StorageError: true
Actual results: azblob.InternalError
error is *azblob.InternalError: ===== RESPONSE ERROR (ErrorCode=BlobNotFound) =====
Description=, Details: (none)
error is azblob.StorageError: false
And I didn't find a way to get the original error code - azblob.StorageError / ErrorCode
Thank you!
Related issue: https://github.com/Azure/azure-storage-blob-go/issues/58
@zezha-msft could you kindly have someone look into this
@mohsha-msft I believe a relevant change just happened but it's not released yet, does it address this issue?
@mohsha-msft I believe a relevant change just happened but it's not released yet, does it address this issue?
Could you provide a way how to access this StorageError? I'm having the same issue while using 0.4.1 which is released in May.
Hi @deiter! Azure Core introduced https://github.com/Azure/azure-sdk-for-go/blob/main/sdk/azcore/errors.go#L14 which can be cast using:
var responseErr *azcore.ResponseError
errors.As(err, &responseErr)
this will be available in the next release.
The usage of *azcore.ResponseError
has been released in [email protected]
.