[@azure/storage-blob] Top level error fields missing data
See original GitHub issue- Package Name: @azure/storage-blob
- Package Version: 12.3.0
- Operating system:
- nodejs
- version: 14.15.1
- typescript
- version: 4.1.3
Describe the bug
When encountering a rest error, specifically in my case an error downloading a non-existing blob, I noticed the following top-level fields missing:
- code (undefined)
- message (empty string)
error.details?.errorCode
contains the ContainerNotFound
or BlobNotFound
message but I was wondering if having the top-level error fields missing might lead to confusion
To Reproduce Steps to reproduce the behavior:
The following code snippet should do it:
export async function test() {
const STORAGE_CONNECTION_STRING = "REPLACE WITH CONNECTION STRING"
const service = BlobServiceClient.fromConnectionString(
STORAGE_CONNECTION_STRING
);
try {
let container = service.getContainerClient("blobs");
let client = container.getBlobClient("does-not-exist.txt");
let buffer = await client.downloadToBuffer();
} catch (error) {
console.log(error.details?.errorCode); // ContainerNotFound or BlobNotFound
if (error instanceof RestError) {
console.log(error.code, error.statusCode, error.message); // undefined, 404, ""
}
}
}
Expected behavior
My first thought is that error.message should show the same message that I see when I let the exception propagate, and that error.code should have some meaningful value. I don’t know if it should be BlobNotFound
like in error.details?.errorCode
or mirror error.statusCode
but I can definitely see someone falling into this pit by using IntelliSense.
Additional context
The example is helpful here, but you have to know to look for it.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (6 by maintainers)
Top GitHub Comments
This is great to hear!
@jeremymeng Can we add a similar comment in #5796 just in case anyone lands there?
This has been fixed.