question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Generic Exception For Using SDK in Azure Pipeline

See original GitHub issue

Hi,

Exceptions in rest api requests are easy. We can use the response.status_code for creating the desired logic. But in SDK, there isn’t any clear results. Consider this code that I used in Pipeline task:

result = network_client.network_interfaces.begin_create_or_update(
        rg_name,
        nic_name,
        parameters=params).result() 

When I use the exception like except AzureHttpError as error the output is Code: ResourceNotFound. That I’m not sure how can be used for custom condition in task because is not generic.

Is there any right way to handling error for custom condition?

Best Jasmine

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
anotherancientaliencommented, Mar 31, 2022

@kristapratico Krista! You are an angel! AzureHttpError didn’t response the status_code but HttpResponseError working like charm! Thank you!

0reactions
kristapraticocommented, Mar 31, 2022

@anotherancientalien thanks. Just so I understand your question, are you looking for the HTTP status code on the SDK error? The status code is exposed on the exception, like the below:

from azure.core.exceptions import HttpResponseError

try:
    result = network_client.network_interfaces.begin_create_or_update(
            rg_name,
            nic_name,
            parameters=params).result()
except HttpResponseError as error:
    print(error.status_code)  # HTTP status code, maybe 404 for a ResouceNotFound code

Let me know if I misinterpreted, though!

Read more comments on GitHub >

github_iconTop Results From Across the Web

azure-iot-sdk-python/pipeline_exceptions.py at main - GitHub
A Python SDK for connecting devices to Microsoft Azure IoT services ... """This module defines exceptions that may be raised from a pipeline"""....
Read more >
Handle errors and exceptions in Azure Logic Apps
How to handle errors and exceptions that happen in automated tasks and workflows created by using Azure Logic Apps.
Read more >
REST API -Exception - The pipeline is not valid. The pipeline ...
Hi Team,. We are trying automate the build-release pipeline import-export process using azure DevOps Web API and asp.net. Now I am facing below...
Read more >
General Guidelines: Implementation | Azure SDKs
Hierarchies of clients inherit parent client configuration unless explicitly changed or overridden. Exceptions to this requirement are as follows: Log level, ...
Read more >
Source code for azure.core.pipeline._base - NET
_policy.on_exception, request) raise else: _await_result(self. ... [docs]class Pipeline(AbstractContextManager, Generic[HTTPRequestType, HTTPResponseType]): ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found