2

I am trying to implement a job which reads from Azure Queue and writes into db. occasionally some errors are raised from the Azure server such as timeout, server busy etc. How to handle such errors in the code, I tried ti run the code in a try catch loop but, I am not able to identify Azure errors? I triedn to import WindowsAzureError from azure , but it doesn't work (no such module to import)?

Which is a good way to handle errors in this case?

Ameen Rashad
  • 514
  • 6
  • 17

2 Answers2

4

If you're using 0.30+ all errors that occur after the request to the service has been will extend from AzureException. AzureException can be found in the azure.common package which Azure storage takes a dependency on. Errors which are thrown if invalid args are passed to a method (ex None for the queue name) might not extend from this and will be standard Python exception like ValueError.

Emily Gerner
  • 2,427
  • 16
  • 16
3

Thanks @Terran,

exception azure.common.AzureConflictHttpError(message, status_code) Bases: azure.common.AzureHttpError

exception azure.common.AzureException Bases: exceptions.Exception

exception azure.common.AzureHttpError(message, status_code) Bases: azure.common.AzureException

exception azure.common.AzureMissingResourceHttpError(message, status_code) Bases: azure.common.AzureHttpError

This helped me.. http://azure-sdk-for-python.readthedocs.org/en/latest/ref/azure.common.html

Ameen Rashad
  • 514
  • 6
  • 17
  • 2
    Microsoft shamefully broke the above link. Updated link to same material: https://learn.microsoft.com/en-us/python/api/azure-common/azure.common – remeika Jul 10 '19 at 21:37