don't panic on failure
This commit is contained in:
parent
8419f1654e
commit
923fa7aa9b
2 changed files with 8 additions and 4 deletions
|
@ -1,6 +1,6 @@
|
||||||
use std::ops::{Mul, Add};
|
use std::ops::{Mul, Add};
|
||||||
|
|
||||||
use log::{trace, warn, info};
|
use log::{trace, warn, info, error};
|
||||||
use nalgebra::Vector2;
|
use nalgebra::Vector2;
|
||||||
use serde::{Serialize, Deserialize};
|
use serde::{Serialize, Deserialize};
|
||||||
use time::OffsetDateTime;
|
use time::OffsetDateTime;
|
||||||
|
@ -142,7 +142,9 @@ impl Task for TreeFarm {
|
||||||
fn run(&mut self,turtle:TurtleCommander) -> AbortHandle {
|
fn run(&mut self,turtle:TurtleCommander) -> AbortHandle {
|
||||||
let frozen = self.clone();
|
let frozen = self.clone();
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
frozen.sweep(turtle).await.unwrap();
|
if let None = frozen.sweep(turtle).await {
|
||||||
|
error!("felling at {} failed", frozen.position);
|
||||||
|
}
|
||||||
}).abort_handle()
|
}).abort_handle()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::sync::{Arc, atomic::{AtomicUsize, Ordering, AtomicI32}};
|
use std::sync::{Arc, atomic::{AtomicUsize, Ordering, AtomicI32}};
|
||||||
|
|
||||||
use log::{info, warn};
|
use log::{info, warn, error};
|
||||||
use serde::{Serialize, Deserialize};
|
use serde::{Serialize, Deserialize};
|
||||||
use tokio::task::{JoinHandle, AbortHandle};
|
use tokio::task::{JoinHandle, AbortHandle};
|
||||||
use typetag::serde;
|
use typetag::serde;
|
||||||
|
@ -263,7 +263,9 @@ impl Task for Quarry {
|
||||||
// TODO: handle failure
|
// TODO: handle failure
|
||||||
// another turtle should get the next chunk while this is in flight, but program
|
// another turtle should get the next chunk while this is in flight, but program
|
||||||
// termination or a None return should reschedule the chunk
|
// termination or a None return should reschedule the chunk
|
||||||
mine_chunk_and_sweep(turtle, abs_pos, max_chunk).await.unwrap();
|
if let None = mine_chunk_and_sweep(turtle, abs_pos, max_chunk).await {
|
||||||
|
error!("mining at {abs_pos} failed");
|
||||||
|
}
|
||||||
owned.fetch_sub(1, Ordering::AcqRel);
|
owned.fetch_sub(1, Ordering::AcqRel);
|
||||||
}).abort_handle()
|
}).abort_handle()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue