update a cuople error messages
This commit is contained in:
parent
82f8b0932c
commit
867785422c
2 changed files with 13 additions and 3 deletions
|
|
@ -55,6 +55,16 @@ pub enum ManagedTorrentState {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ManagedTorrentState {
|
impl ManagedTorrentState {
|
||||||
|
pub fn name(&self) -> &'static str {
|
||||||
|
match self {
|
||||||
|
ManagedTorrentState::Initializing(_) => "initializing",
|
||||||
|
ManagedTorrentState::Paused(_) => "paused",
|
||||||
|
ManagedTorrentState::Live(_) => "live",
|
||||||
|
ManagedTorrentState::Error(_) => "error",
|
||||||
|
ManagedTorrentState::None => "<invalid: none>",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn assert_paused(self) -> TorrentStatePaused {
|
fn assert_paused(self) -> TorrentStatePaused {
|
||||||
match self {
|
match self {
|
||||||
Self::Paused(paused) => paused,
|
Self::Paused(paused) => paused,
|
||||||
|
|
|
||||||
|
|
@ -300,9 +300,9 @@ impl ManagedTorrent {
|
||||||
let files = match s {
|
let files = match s {
|
||||||
crate::ManagedTorrentState::Paused(p) => &p.files,
|
crate::ManagedTorrentState::Paused(p) => &p.files,
|
||||||
crate::ManagedTorrentState::Live(l) => &l.files,
|
crate::ManagedTorrentState::Live(l) => &l.files,
|
||||||
_ => anyhow::bail!("invalid state"),
|
s => anyhow::bail!("with_opened_file: invalid state {}", s.name()),
|
||||||
};
|
};
|
||||||
let fd = files.get(file_id).context("invalid file")?;
|
let fd = files.get(file_id).context("invalid file id")?;
|
||||||
Ok(f(fd))
|
Ok(f(fd))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -311,7 +311,7 @@ impl ManagedTorrent {
|
||||||
self.with_state(|s| match s {
|
self.with_state(|s| match s {
|
||||||
crate::ManagedTorrentState::Paused(p) => Ok(p.streams.clone()),
|
crate::ManagedTorrentState::Paused(p) => Ok(p.streams.clone()),
|
||||||
crate::ManagedTorrentState::Live(l) => Ok(l.streams.clone()),
|
crate::ManagedTorrentState::Live(l) => Ok(l.streams.clone()),
|
||||||
_ => anyhow::bail!("invalid state"),
|
s => anyhow::bail!("streams: invalid state {}", s.name()),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue