mirror of
https://github.com/scottlamb/moonfire-nvr.git
synced 2025-11-09 21:49:46 -05:00
use typed errors in /view.mp4 path
This fixes #178. Before, everything got translated to 5xx status; now it produces the correct type in several cases. Ideally I'd get rid of the untyped errors in all of web.rs; this is a small step.
This commit is contained in:
@@ -11,7 +11,7 @@ use core::borrow::Borrow;
|
||||
use core::str::FromStr;
|
||||
use db::dir::SampleFileDir;
|
||||
use db::{auth, recording};
|
||||
use failure::{bail, format_err, Error};
|
||||
use failure::{format_err, Error};
|
||||
use fnv::FnvHashMap;
|
||||
use futures::stream::StreamExt;
|
||||
use futures::{future::Either, sink::SinkExt};
|
||||
@@ -860,7 +860,8 @@ impl Service {
|
||||
|
||||
if let Some(o) = s.open_id {
|
||||
if r.open_id != o {
|
||||
bail!(
|
||||
bail_t!(
|
||||
NotFound,
|
||||
"recording {} has open id {}, requested {}",
|
||||
r.id,
|
||||
r.open_id,
|
||||
@@ -872,9 +873,14 @@ impl Service {
|
||||
// Check for missing recordings.
|
||||
match prev {
|
||||
None if recording_id == s.ids.start => {}
|
||||
None => bail!("no such recording {}/{}", stream_id, s.ids.start),
|
||||
None => bail_t!(
|
||||
NotFound,
|
||||
"no such recording {}/{}",
|
||||
stream_id,
|
||||
s.ids.start
|
||||
),
|
||||
Some(id) if r.id.recording() != id + 1 => {
|
||||
bail!("no such recording {}/{}", stream_id, id + 1);
|
||||
bail_t!(NotFound, "no such recording {}/{}", stream_id, id + 1);
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
@@ -913,8 +919,7 @@ impl Service {
|
||||
}
|
||||
cur_off += wd;
|
||||
Ok(())
|
||||
})
|
||||
.map_err(internal_server_err)?;
|
||||
})?;
|
||||
|
||||
// Check for missing recordings.
|
||||
match prev {
|
||||
|
||||
Reference in New Issue
Block a user