Update stream errors with additional error information (#62900)

This commit is contained in:
Allen Porter 2021-12-29 09:57:14 -08:00 committed by GitHub
parent 2f7fa962b4
commit 23384ee1e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -448,7 +448,7 @@ def stream_worker(
container = av.open(source, options=options, timeout=SOURCE_TIMEOUT)
except av.AVError as err:
raise StreamWorkerError(
"Error opening stream %s" % redact_credentials(str(source))
f"Error opening stream ({err.type}, {err.strerror}) {redact_credentials(str(source))}"
) from err
try:
video_stream = container.streams.video[0]

View File

@ -716,7 +716,10 @@ async def test_worker_log(hass, caplog):
av_open.side_effect = av.error.InvalidDataError(-2, "error")
run_worker(hass, stream, "https://abcd:efgh@foo.bar")
await hass.async_block_till_done()
assert str(err.value) == "Error opening stream https://****:****@foo.bar"
assert (
str(err.value)
== "Error opening stream (ERRORTYPE_-2, error) https://****:****@foo.bar"
)
assert "https://abcd:efgh@foo.bar" not in caplog.text