Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,7 @@ demoCA/

# e2e
**/_e2e_settings.json

# AutoRest codegen scratch (local install of @autorest/core, @autorest/python)
.autorest/
node_modules/
6 changes: 3 additions & 3 deletions samples/get_digital_twin_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# --------------------------------------------------------------------------

import os
import msrest
from azure.core.exceptions import HttpResponseError

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it the standard practice in the Azure SDK to have the application consume azure.core.exceptions for error handling, or is it more conventional for the libraries to re-export the azure core errors?

The latter would probably be less brittle going forth, but obviously only do that if that's the preferred Azure SDK approach.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct import from azure.core.exceptions is the standard. The Azure SDK for Python design guidelines treat azure-core as a shared, always-present dependency of every client library, and explicitly discourage libraries from re-exporting its exception types. Consumers are expected to from azure.core.exceptions import HttpResponseError etc

from azure.iot.hub import DigitalTwinClient


Expand All @@ -25,8 +25,8 @@
print("No digital_twin found")


except msrest.exceptions.HttpOperationError as ex:
print("HttpOperationError error {0}".format(ex.response.text))
except HttpResponseError as ex:
print("HttpResponseError error {0}".format(ex))
except Exception as exc:
print("Unexpected error {0}".format(exc))
except KeyboardInterrupt:
Expand Down
6 changes: 3 additions & 3 deletions samples/invoke_command_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# --------------------------------------------------------------------------

import os
import msrest
from azure.core.exceptions import HttpResponseError
from azure.iot.hub import DigitalTwinClient


Expand All @@ -30,8 +30,8 @@
else:
print("No invoke_command_result found")

except msrest.exceptions.HttpOperationError as ex:
print("HttpOperationError error {0}".format(ex.response.text))
except HttpResponseError as ex:
print("HttpResponseError error {0}".format(ex))
except Exception as exc:
print("Unexpected error {0}".format(exc))
except KeyboardInterrupt:
Expand Down
6 changes: 3 additions & 3 deletions samples/invoke_component_command_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# --------------------------------------------------------------------------

import os
import msrest
from azure.core.exceptions import HttpResponseError
from azure.iot.hub import DigitalTwinClient


Expand Down Expand Up @@ -38,8 +38,8 @@
else:
print("No invoke_component_command_result found")

except msrest.exceptions.HttpOperationError as ex:
print("HttpOperationError error {0}".format(ex.response.text))
except HttpResponseError as ex:
print("HttpResponseError error {0}".format(ex))
except Exception as exc:
print("Unexpected error {0}".format(exc))
except KeyboardInterrupt:
Expand Down
6 changes: 3 additions & 3 deletions samples/iothub_configuration_manager_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# --------------------------------------------------------------------------

import os
import msrest
from azure.core.exceptions import HttpResponseError
from azure.iot.hub import IoTHubConfigurationManager
from azure.iot.hub.models import Configuration, ConfigurationContent, ConfigurationMetrics

Expand Down Expand Up @@ -69,8 +69,8 @@ def create_configuration(config_id):
else:
print("No configuration found")

except msrest.exceptions.HttpOperationError as ex:
print("HttpOperationError error {0}".format(ex.response.text))
except HttpResponseError as ex:
print("HttpResponseError error {0}".format(ex))
except Exception as ex:
print("Unexpected error {0}".format(ex))
except KeyboardInterrupt:
Expand Down
6 changes: 3 additions & 3 deletions samples/iothub_job_manager_import_export_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# --------------------------------------------------------------------------

import os
import msrest
from azure.core.exceptions import HttpResponseError
from azure.iot.hub import IoTHubJobManager
from azure.iot.hub.models import JobProperties

Expand Down Expand Up @@ -85,8 +85,8 @@ def print_export_import_jobs(title, export_import_jobs):
)
print(cancel_export_import_job)

except msrest.exceptions.HttpOperationError as ex:
print("HttpOperationError error {0}".format(ex.response.text))
except HttpResponseError as ex:
print("HttpResponseError error {0}".format(ex))
except Exception as ex:
print("Unexpected error {0}".format(ex))
except KeyboardInterrupt:
Expand Down
6 changes: 3 additions & 3 deletions samples/iothub_job_manager_method_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import uuid
import time
import datetime
import msrest
import pprint
from azure.core.exceptions import HttpResponseError
from azure.iot.hub import IoTHubJobManager
from azure.iot.hub.models import JobRequest, CloudToDeviceMethod

Expand Down Expand Up @@ -56,8 +56,8 @@ def print_job_response(title, response):
break
time.sleep(5)

except msrest.exceptions.HttpOperationError as ex:
print("HttpOperationError error {0}".format(ex.response.text))
except HttpResponseError as ex:
print("HttpResponseError error {0}".format(ex))
except Exception as ex:
print("Unexpected error {0}".format(ex))
except KeyboardInterrupt:
Expand Down
6 changes: 3 additions & 3 deletions samples/iothub_job_manager_twin_update_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import datetime
import time
import uuid
import msrest
import pprint
from azure.core.exceptions import HttpResponseError
from azure.iot.hub import IoTHubJobManager
from azure.iot.hub.models import JobRequest, Twin, TwinProperties

Expand Down Expand Up @@ -50,8 +50,8 @@ def print_job_response(title, response):
break
time.sleep(5)

except msrest.exceptions.HttpOperationError as ex:
print("HttpOperationError error {0}".format(ex.response.text))
except HttpResponseError as ex:
print("HttpResponseError error {0}".format(ex))
except Exception as ex:
print("Unexpected error {0}".format(ex))
except KeyboardInterrupt:
Expand Down
6 changes: 3 additions & 3 deletions samples/iothub_registry_manager_bulk_create_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
# --------------------------------------------------------------------------

import os
import msrest
import uuid
import base64
from azure.core.exceptions import HttpResponseError
from azure.iot.hub import IoTHubRegistryManager
from azure.iot.hub.models import ExportImportDevice, AuthenticationMechanism, SymmetricKey

Expand Down Expand Up @@ -83,8 +83,8 @@ def print_device_info(title, iothub_device):
# Set registry manager object to `None` so all open files get closed
iothub_registry_manager = None

except msrest.exceptions.HttpOperationError as ex:
print("HttpOperationError error {0}".format(ex.response.text))
except HttpResponseError as ex:
print("HttpResponseError error {0}".format(ex))
except Exception as ex:
print("Unexpected error {0}".format(ex))
except KeyboardInterrupt:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# --------------------------------------------------------------------------

import os
import msrest
from azure.core.exceptions import HttpResponseError
from azure.iot.hub import IoTHubRegistryManager, TransportType

connection_str = os.getenv("IOTHUB_CONNECTION_STRING")
Expand Down Expand Up @@ -35,8 +35,8 @@
# Set registry manager object to `None` so all open files get closed
iothub_registry_manager = None

except msrest.exceptions.HttpOperationError as ex:
print("HttpOperationError error {0}".format(ex.response.text))
except HttpResponseError as ex:
print("HttpResponseError error {0}".format(ex))
except Exception as ex:
print("Unexpected error {0}".format(ex))
except KeyboardInterrupt:
Expand Down
6 changes: 3 additions & 3 deletions samples/iothub_registry_manager_c2d_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# --------------------------------------------------------------------------

import os
import msrest
from azure.core.exceptions import HttpResponseError
from azure.iot.hub import IoTHubRegistryManager

connection_str = os.getenv("IOTHUB_CONNECTION_STRING")
Expand Down Expand Up @@ -35,8 +35,8 @@
# Set registry manager object to `None` so all open files get closed
iothub_registry_manager = None

except msrest.exceptions.HttpOperationError as ex:
print("HttpOperationError error {0}".format(ex.response.text))
except HttpResponseError as ex:
print("HttpResponseError error {0}".format(ex))
except Exception as ex:
print("Unexpected error {0}".format(ex))
except KeyboardInterrupt:
Expand Down
6 changes: 3 additions & 3 deletions samples/iothub_registry_manager_edge_device_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
# --------------------------------------------------------------------------

import os
import msrest
import uuid
import base64
from azure.core.exceptions import HttpResponseError
from azure.iot.hub import IoTHubRegistryManager

iothub_connection_str = os.getenv("IOTHUB_CONNECTION_STRING")
Expand Down Expand Up @@ -71,8 +71,8 @@ def print_device_info(title, iothub_device):
# Set registry manager object to `None` so all open files get closed
iothub_registry_manager = None

except msrest.exceptions.HttpOperationError as ex:
print("HttpOperationError error {0}".format(ex.response.text))
except HttpResponseError as ex:
print("HttpResponseError error {0}".format(ex))
except Exception as ex:
print("Unexpected error {0}".format(ex))
except KeyboardInterrupt:
Expand Down
6 changes: 3 additions & 3 deletions samples/iothub_registry_manager_method_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# --------------------------------------------------------------------------

import os
import msrest
from azure.core.exceptions import HttpResponseError
from azure.iot.hub import IoTHubRegistryManager
from azure.iot.hub.models import CloudToDeviceMethod

Expand All @@ -26,8 +26,8 @@
# Set registry manager object to `None` so all open files get closed
iothub_registry_manager = None

except msrest.exceptions.HttpOperationError as ex:
print("HttpOperationError error {0}".format(ex.response.text))
except HttpResponseError as ex:
print("HttpResponseError error {0}".format(ex))
except Exception as ex:
print("Unexpected error {0}".format(ex))
except KeyboardInterrupt:
Expand Down
6 changes: 3 additions & 3 deletions samples/iothub_registry_manager_module_method_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
# --------------------------------------------------------------------------

import os
import msrest
import uuid
import base64
from azure.core.exceptions import HttpResponseError
from azure.iot.hub import IoTHubRegistryManager
from azure.iot.hub.models import CloudToDeviceMethod

Expand Down Expand Up @@ -39,8 +39,8 @@
# Set registry manager object to `None` so all open files get closed
iothub_registry_manager = None

except msrest.exceptions.HttpOperationError as ex:
print("HttpOperationError error {0}".format(ex.response.text))
except HttpResponseError as ex:
print("HttpResponseError error {0}".format(ex))
except Exception as ex:
print("Unexpected error {0}".format(ex))
except KeyboardInterrupt:
Expand Down
6 changes: 3 additions & 3 deletions samples/iothub_registry_manager_module_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
# --------------------------------------------------------------------------

import os
import msrest
import uuid
import base64
from azure.core.exceptions import HttpResponseError
from azure.iot.hub import IoTHubRegistryManager
from azure.iot.hub.models import Twin, TwinProperties

Expand Down Expand Up @@ -107,8 +107,8 @@ def print_module_info(title, iothub_module):
# Set registry manager object to `None` so all open files get closed
iothub_registry_manager = None

except msrest.exceptions.HttpOperationError as ex:
print("HttpOperationError error {0}".format(ex.response.text))
except HttpResponseError as ex:
print("HttpResponseError error {0}".format(ex))
except Exception as ex:
print("Unexpected error {0}".format(ex))
except KeyboardInterrupt:
Expand Down
6 changes: 3 additions & 3 deletions samples/iothub_registry_manager_query_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# --------------------------------------------------------------------------

import os
import msrest
from azure.core.exceptions import HttpResponseError
from azure.iot.hub import IoTHubRegistryManager
from azure.iot.hub.models import QuerySpecification

Expand Down Expand Up @@ -77,8 +77,8 @@ def print_query_result(title, query_result):
iothub_registry_manager = None


except msrest.exceptions.HttpOperationError as ex:
print("HttpOperationError error {0}".format(ex.response.text))
except HttpResponseError as ex:
print("HttpResponseError error {0}".format(ex))
except Exception as ex:
print("Unexpected error {0}".format(ex))
except KeyboardInterrupt:
Expand Down
6 changes: 3 additions & 3 deletions samples/iothub_registry_manager_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
# --------------------------------------------------------------------------

import os
import msrest
import uuid
import base64
from azure.core.exceptions import HttpResponseError
from azure.iot.hub import IoTHubRegistryManager
from azure.iot.hub.models import Twin, TwinProperties

Expand Down Expand Up @@ -127,8 +127,8 @@ def print_device_info(title, iothub_device):
# Set registry manager object to `None` so all open files get closed
iothub_registry_manager = None

except msrest.exceptions.HttpOperationError as ex:
print("HttpOperationError error {0}".format(ex.response.text))
except HttpResponseError as ex:
print("HttpResponseError error {0}".format(ex))
except Exception as ex:
print("Unexpected error {0}".format(ex))
except KeyboardInterrupt:
Expand Down
6 changes: 3 additions & 3 deletions samples/iothub_registry_manager_statistics_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# --------------------------------------------------------------------------

import os
import msrest
from azure.core.exceptions import HttpResponseError
from azure.iot.hub import IoTHubRegistryManager

connection_str = os.getenv("IOTHUB_CONNECTION_STRING")
Expand Down Expand Up @@ -48,8 +48,8 @@
# Set registry manager object to `None` so all open files get closed
iothub_registry_manager = None

except msrest.exceptions.HttpOperationError as ex:
print("HttpOperationError error {0}".format(ex.response.text))
except HttpResponseError as ex:
print("HttpResponseError error {0}".format(ex))
except Exception as ex:
print("Unexpected error {0}".format(ex))
except KeyboardInterrupt:
Expand Down
6 changes: 3 additions & 3 deletions samples/iothub_registry_manager_token_credential_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
# --------------------------------------------------------------------------

import os
import msrest
import uuid
import base64
from azure.core.exceptions import HttpResponseError
from azure.iot.hub import IoTHubRegistryManager
from azure.identity import DefaultAzureCredential

Expand Down Expand Up @@ -88,8 +88,8 @@ def print_device_info(title, iothub_device):
# Set registry manager object to `None` so all open files get closed
iothub_registry_manager = None

except msrest.exceptions.HttpOperationError as ex:
print("HttpOperationError error {0}".format(ex.response.text))
except HttpResponseError as ex:
print("HttpResponseError error {0}".format(ex))
except Exception as ex:
print("Unexpected error {0}".format(ex))
except KeyboardInterrupt:
Expand Down
Loading