improve error formatting
This commit is contained in:
parent
1d98cbd1ff
commit
3cd57801c8
18
src/main.rs
18
src/main.rs
|
@ -171,7 +171,7 @@ impl Resources {
|
||||||
let (etag, last_modified, events) =
|
let (etag, last_modified, events) =
|
||||||
self.worker_fetch(&cal_id, &cal_opts, etag, last_modified)
|
self.worker_fetch(&cal_id, &cal_opts, etag, last_modified)
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
let msg = format!("{:?}", e);
|
let msg = format!("{}", e);
|
||||||
println!("[{}] {}", cal_id, msg);
|
println!("[{}] {}", cal_id, msg);
|
||||||
let _ = diesel::update(calendars)
|
let _ = diesel::update(calendars)
|
||||||
.filter(schema::calendars::dsl::id.eq(cal_id.clone()))
|
.filter(schema::calendars::dsl::id.eq(cal_id.clone()))
|
||||||
|
@ -211,7 +211,7 @@ impl Resources {
|
||||||
let mut done = false;
|
let mut done = false;
|
||||||
while ! done {
|
while ! done {
|
||||||
done = self.worker_job(&db)
|
done = self.worker_job(&db)
|
||||||
.map_err(|e| println!("{:?}", e))
|
.map_err(|e| println!("{}", e))
|
||||||
.unwrap_or(false);
|
.unwrap_or(false);
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -251,6 +251,18 @@ impl From<std::io::Error> for Error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Display for Error {
|
||||||
|
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
|
||||||
|
match self {
|
||||||
|
Error::DbConnection(e) => e.fmt(fmt),
|
||||||
|
Error::Db(e) => e.fmt(fmt),
|
||||||
|
Error::Http(e) => e.fmt(fmt),
|
||||||
|
Error::Io(e) => e.fmt(fmt),
|
||||||
|
Error::Message(e) => e.fmt(fmt),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let config_file = read_to_string("config.yaml")
|
let config_file = read_to_string("config.yaml")
|
||||||
.expect("config.yaml");
|
.expect("config.yaml");
|
||||||
|
@ -267,7 +279,7 @@ fn main() {
|
||||||
let workers: Vec<_> = (0..cpus)
|
let workers: Vec<_> = (0..cpus)
|
||||||
.map(|_| s.spawn(|_| {
|
.map(|_| s.spawn(|_| {
|
||||||
res.worker_loop()
|
res.worker_loop()
|
||||||
.map_err(|e| println!("{:?}", e))
|
.map_err(|e| println!("{}", e))
|
||||||
}))
|
}))
|
||||||
.collect();
|
.collect();
|
||||||
for worker in workers.into_iter() {
|
for worker in workers.into_iter() {
|
||||||
|
|
Loading…
Reference in New Issue