mirror of
https://github.com/gitui-org/gitui
synced 2026-05-23 00:48:35 +00:00
remove some excepts
This commit is contained in:
parent
9b6dd60fe0
commit
3ff8584438
3 changed files with 32 additions and 6 deletions
21
async_utils/src/error.rs
Normal file
21
async_utils/src/error.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum Error {
|
||||
#[error("`{0}`")]
|
||||
Generic(String),
|
||||
}
|
||||
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
impl<T> From<crossbeam_channel::SendError<T>> for Error {
|
||||
fn from(error: crossbeam_channel::SendError<T>) -> Self {
|
||||
Self::Generic(format!("send error: {}", error))
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> From<std::sync::PoisonError<T>> for Error {
|
||||
fn from(error: std::sync::PoisonError<T>) -> Self {
|
||||
Self::Generic(format!("poison error: {}", error))
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,7 @@
|
|||
mod error;
|
||||
|
||||
use crossbeam_channel::Sender;
|
||||
use error::Result;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
pub trait AsyncJob: Send + Sync + Clone {
|
||||
|
|
@ -70,7 +73,9 @@ impl<J: 'static + AsyncJob, T: Copy + Send + 'static>
|
|||
let self_arc = self.clone();
|
||||
|
||||
rayon_core::spawn(move || {
|
||||
self_arc.run_job(task);
|
||||
if let Err(e) = self_arc.run_job(task) {
|
||||
log::error!("async job error: {}", e);
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
|
|
@ -79,11 +84,10 @@ impl<J: 'static + AsyncJob, T: Copy + Send + 'static>
|
|||
false
|
||||
}
|
||||
|
||||
//TODO: return Result
|
||||
fn run_job(&self, mut task: J) {
|
||||
fn run_job(&self, mut task: J) -> Result<()> {
|
||||
//limit the pending scope
|
||||
{
|
||||
let _pending = self.pending.lock().expect("");
|
||||
let _pending = self.pending.lock()?;
|
||||
|
||||
task.run();
|
||||
|
||||
|
|
@ -91,10 +95,12 @@ impl<J: 'static + AsyncJob, T: Copy + Send + 'static>
|
|||
*last = Some(task);
|
||||
}
|
||||
|
||||
self.sender.send(self.notification).expect("send failed");
|
||||
self.sender.send(self.notification)?;
|
||||
}
|
||||
|
||||
self.check_for_job();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
///
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ pub struct RevisionFilesComponent {
|
|||
theme: SharedTheme,
|
||||
//TODO: store TreeFiles in `tree`
|
||||
files: Vec<TreeFile>,
|
||||
// current_file: Option<(String, Either<ui::SyntaxText, String>)>,
|
||||
current_file: SyntaxTextComponent,
|
||||
tree: FileTree,
|
||||
scroll_top: Cell<usize>,
|
||||
|
|
|
|||
Loading…
Reference in a new issue