Use map_err(From::from) instead of ? into Ok() wrapping pattern.
This commit is contained in:
parent
0e16f0acb0
commit
5da002fe6d
@ -173,8 +173,7 @@ impl Episode {
|
|||||||
pub fn set_played_now(&mut self) -> Result<()> {
|
pub fn set_played_now(&mut self) -> Result<()> {
|
||||||
let epoch = Utc::now().timestamp() as i32;
|
let epoch = Utc::now().timestamp() as i32;
|
||||||
self.set_played(Some(epoch));
|
self.set_played(Some(epoch));
|
||||||
self.save()?;
|
self.save().map(|_| ())
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper method to easily save/"sync" current state of self to the Database.
|
/// Helper method to easily save/"sync" current state of self to the Database.
|
||||||
@ -182,7 +181,7 @@ impl Episode {
|
|||||||
let db = connection();
|
let db = connection();
|
||||||
let tempdb = db.get()?;
|
let tempdb = db.get()?;
|
||||||
|
|
||||||
Ok(self.save_changes::<Episode>(&*tempdb)?)
|
self.save_changes::<Episode>(&*tempdb).map_err(From::from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -329,8 +328,7 @@ impl EpisodeWidgetQuery {
|
|||||||
pub fn set_played_now(&mut self) -> Result<()> {
|
pub fn set_played_now(&mut self) -> Result<()> {
|
||||||
let epoch = Utc::now().timestamp() as i32;
|
let epoch = Utc::now().timestamp() as i32;
|
||||||
self.set_played(Some(epoch));
|
self.set_played(Some(epoch));
|
||||||
self.save()?;
|
self.save().map(|_| ())
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper method to easily save/"sync" current state of self to the Database.
|
/// Helper method to easily save/"sync" current state of self to the Database.
|
||||||
@ -340,9 +338,10 @@ impl EpisodeWidgetQuery {
|
|||||||
let db = connection();
|
let db = connection();
|
||||||
let tempdb = db.get()?;
|
let tempdb = db.get()?;
|
||||||
|
|
||||||
Ok(diesel::update(episode.filter(rowid.eq(self.rowid)))
|
diesel::update(episode.filter(rowid.eq(self.rowid)))
|
||||||
.set(self)
|
.set(self)
|
||||||
.execute(&*tempdb)?)
|
.execute(&*tempdb)
|
||||||
|
.map_err(From::from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -406,9 +405,10 @@ impl EpisodeCleanerQuery {
|
|||||||
let db = connection();
|
let db = connection();
|
||||||
let tempdb = db.get()?;
|
let tempdb = db.get()?;
|
||||||
|
|
||||||
Ok(diesel::update(episode.filter(rowid.eq(self.rowid())))
|
diesel::update(episode.filter(rowid.eq(self.rowid())))
|
||||||
.set(self)
|
.set(self)
|
||||||
.execute(&*tempdb)?)
|
.execute(&*tempdb)
|
||||||
|
.map_err(From::from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -113,7 +113,7 @@ impl Podcast {
|
|||||||
let db = connection();
|
let db = connection();
|
||||||
let tempdb = db.get()?;
|
let tempdb = db.get()?;
|
||||||
|
|
||||||
Ok(self.save_changes::<Podcast>(&*tempdb)?)
|
self.save_changes::<Podcast>(&*tempdb).map_err(From::from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user