Azure / Azure/azure-sdk-for-java
[FEATURE REQ] Throw FileNotFoundException when blob does not exist
- Dominant language
- Java
- Stars
- 2.6k
- Forks
- 2.2k
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 178
Description
**Is your feature request related to a problem? Please describe.**
When building an _InputStream_ with _Files.newInputStream(myPath)_ from a Azure Blob Storage using _azure-storage-blob-nio_, if the blob does not exist, the exception thrown by _AzureFileSystemProvider_ is _IOException_ with the message:
`Path either does not exist or points to a directory.Path must point to a file. Path: my_directory/my_path`
**Describe the solution you'd like**
As according to the [Blob API errors](https://learn.microsoft.com/en-us/rest/api/storageservices/blob-service-error-codes), there is a _BlobNotFound_ error, which is obviously 404 HTTP code, it would be quite normal to expect a _FileNotFound_ exception in return when the blob does not exist.
**Describe alternatives you've considered**
Solution I have used is to parse the error message and throw a _FileNotFoundException_ if it contains a part of the message mentioned above and if not rethrow the _IOException
**Additional context**
- Azure Storage Blob NIO version : _12.0.0-beta.31_
- Java 21
Contributor guide
Assessment
This issue has not been assessed yet.