improve error msg on timeout opening stream

Before, it'd look like the following, as mentioned in
https://github.com/scottlamb/moonfire-nvr/issues/331:

```
2024-12-09T20:53:24.853572 WARN s-CP3PRO-main streamer{stream="CP3PRO-main"}: moonfire_nvr::streamer: sleeping for 1 s after error err=UNKNOWN
caused by: deadline has elapsed
```

...which isn't as clear as it could be, particularly if you don't notice
the `caused by` bit. After, it should look more like the following:

```
2024-12-09T20:53:24.853572 WARN s-CP3PRO-main streamer{stream="CP3PRO-main"}: moonfire_nvr::streamer: sleeping for 1 s after error err=DEADLINE_EXCEEDED unable to play stream and get first frame within PT30S
caused by: deadline has elapsed
```
This commit is contained in:
Scott Lamb 2024-12-11 15:04:04 -08:00
parent 9256561362
commit 904842cc2d
2 changed files with 9 additions and 2 deletions

View File

@ -11,6 +11,7 @@ even on minor releases, e.g. `v0.7.5` -> `v0.7.6`.
## unreleased
* bump minimum Rust version to 1.81.
* improve error message on timeout opening stream.
## v0.7.17 (2024-09-03)

View File

@ -111,7 +111,13 @@ impl Opener for RealOpener {
),
)
.expect("RetinaStream::play task panicked, see earlier error")
.map_err(|e| err!(Unknown, source(e)))??;
.map_err(|e| {
err!(
DeadlineExceeded,
msg("unable to play stream and get first frame within {RETINA_TIMEOUT:?}"),
source(e),
)
})??;
Ok(Box::new(RetinaStream {
inner: Some(inner),
rt_handle,
@ -302,7 +308,7 @@ impl Stream for RetinaStream {
.map_err(|e| {
err!(
DeadlineExceeded,
msg("timeout getting next frame"),
msg("unable to get next frame within {RETINA_TIMEOUT:?}"),
source(e)
)
})??;