'How do I handle HttpRequestException Connection refused error?
I have a method (pseudo-code) that calls an API.
public apiCall()
{
try {
_client.GetStuff()
}
catch (Exception e) {
// catches HttpRequestException Connection refused exception
// do some logic here if connection is refused
}
}
If I get a System.Net.Http.HttpRequestException: Connection refused how can I capture it in the catch block and handle it?
I thought of using the StatusCode enum but could not find any that correlate to Connection refused.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
