azure.storage.filedatalake.models.StorageErrorException does not exist
See original GitHub issue- Package Name: azure-storage-file-datalake
- Package Version: 12.1.2
- Operating System:Linux
- Python Version: 3.7.3
Describe the bug The docs refer to azure.storage.filedatalake.models.StorageErrorException, but azure.storage.filedatalake.models.StorageErrorException does not seem to exist.
To Reproduce Steps to reproduce the behavior:
>>> import azure.storage.filedatalake
>>> import azure.storage.filedatalake.models
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'azure.storage.filedatalake.models'
>>> import azure.storage.filedatalake.models.StorageErrorException
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'azure.storage.filedatalake.models'
>>> azure.storage.filedatalake._generated.models.StorageErrorException
<class 'azure.storage.filedatalake._generated.models._models_py3.StorageErrorException'>
Expected behavior Documented classes should exist. 😃 Exception classes should be publicly accessible so they may be caught and examined by the caller.
Additional context We catch these exceptions to check for the string ‘This operation is only supported on a hierarchical namespace account.’
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Source code for azure.storage.filedatalake._models - NET
_generated.models import StorageErrorException from azure.storage.blob. ... Additionally, the file system name is available as ``file_system_props["name"]`` ...
Read more >DataLakeStorageException Class - Microsoft Learn
A DataLakeStorageException is thrown whenever Azure Storage successfully returns an error code that is not 200-level.
Read more >Overpass a custom exception but print all the other exceptions
There are several ways of achieving this. Here's one: ... StorageErrorException (currently imported) ... import azure.storage.filedatalake.
Read more >azure-storage-file-datalake - PyPI
FileSystemClient - this client represents interaction with a specific file system, even if that file system does not exist yet. It provides operations...
Read more >Azure File Data Lake client library for Java - javadoc.io
Azure Data Lake Storage is Microsoft's optimized storage solution for for big ... on a particular version of the library that is not...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hi @jazelenk, sorry for the delay on this! you’re right the exceptions docs are not very clear. The azure storage exceptions that are raised at the end of any failed operation are imported from Azure core.
The way we raise this is by using an internal class called
StorageErrorException. This is deserialized byprocess_storage_error(storage_error_exception_object)internally. This simply maps the different possible error codes to the corresponding appropriate Azure core exception which can be caught by the user. You can see the mapping we’re doing here: https://github.com/Azure/azure-sdk-for-python/blob/8504f6d247badd2fd60dce3457f201f9e2b1c079/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/response_handlers.py#L86As for fetching the specific error code of the exception (which - as you mentioned, would be package specific ) you can follow this example:
If for some reason we deserialized an error that is not defined in https://github.com/Azure/azure-sdk-for-python/blob/8504f6d247badd2fd60dce3457f201f9e2b1c079/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/response_handlers.py#L86 we default/raise an
HttpResponseError(you can catch it and use the code above to find out what the error code was)In your case
HierarchicalNamespaceNotEnabledis not being deserialized in our checks so you can do the following:I’m not sure why we even reference
StorageErrorExceptionin our README. I will put out a PR that explains what I have mentioned in this comment 😃 I will link it here once up. Let me know if this makes sense or if you need further help!The check I end up performing is matching
error_codetoHierarchicalNamespaceNotEnabled.