Skip to content

Commit

Permalink
Catch from protocol as failure reason
Browse files Browse the repository at this point in the history
  • Loading branch information
tykling committed Mar 6, 2024
1 parent cdf75a1 commit b077c0e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

- No changes yet
### Fixed
- Catch `httpx.ConnectTimeout` from protocol `doh` as failure reason `timeout`


## [v1.0.0-rc2] - 2024-03-06
Expand Down
5 changes: 5 additions & 0 deletions src/dns_exporter/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,11 @@ def get_dns_response_doh( # noqa: PLR0913
reason = "certificate_error" if "CERTIFICATE_VERIFY_FAILED" in str(e) else "connection_error"
logger.debug(f"Protocol doh raised exception, returning {reason}")
raise ProtocolSpecificError(reason) from e
except httpx.ConnectTimeout as e:
# raised by doh on timeouts
reason = "timeout"
logger.debug(f"Protocol doh raised exception, returning {reason}")
raise ProtocolSpecificError(reason) from e
except OSError as e:
# raised by doh when ca path is not found
logger.debug("Protocol doh unable to find CA path, returning invalid_request_config")
Expand Down

0 comments on commit b077c0e

Please sign in to comment.