don't panic in main
This commit is contained in:
parent
64410f0042
commit
9903508129
|
@ -13,13 +13,13 @@ fn main() -> Result<()> {
|
||||||
match args.next() {
|
match args.next() {
|
||||||
Some(arg) => {
|
Some(arg) => {
|
||||||
let day: usize = arg.parse().expect("Please provide a day number");
|
let day: usize = arg.parse().expect("Please provide a day number");
|
||||||
days[day - 1]().expect("error running day specified");
|
days[day - 1]().unwrap_or_else(|e| eprintln!("error running day specified: {}", e));
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
for (i, day) in days.iter().enumerate() {
|
for (i, day) in days.iter().enumerate() {
|
||||||
let i = i + 1;
|
let i = i + 1;
|
||||||
println!("day{}: ", i);
|
println!("day{}: ", i);
|
||||||
day().unwrap_or_else(|e| panic!("error running day {}: {}", i, e));
|
day().unwrap_or_else(|e| eprintln!("error running day {}: {}", i, e));
|
||||||
println!();
|
println!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,13 +17,13 @@ fn main() -> Result<()> {
|
||||||
match args.next() {
|
match args.next() {
|
||||||
Some(arg) => {
|
Some(arg) => {
|
||||||
let day: usize = arg.parse().expect("Please provide a day number");
|
let day: usize = arg.parse().expect("Please provide a day number");
|
||||||
days[day - 1]().expect("error running day specified");
|
days[day - 1]().unwrap_or_else(|e| eprintln!("error running day specified: {}", e));
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
for (i, day) in days.iter().enumerate() {
|
for (i, day) in days.iter().enumerate() {
|
||||||
let i = i + 1;
|
let i = i + 1;
|
||||||
println!("day{}: ", i);
|
println!("day{}: ", i);
|
||||||
day().unwrap_or_else(|e| panic!("error running day {}: {}", i, e));
|
day().unwrap_or_else(|e| eprintln!("error running day {}: {}", i, e));
|
||||||
println!();
|
println!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,13 +13,13 @@ fn main() -> Result<()> {
|
||||||
match args.next() {
|
match args.next() {
|
||||||
Some(arg) => {
|
Some(arg) => {
|
||||||
let day: usize = arg.parse().expect("Please provide a day number");
|
let day: usize = arg.parse().expect("Please provide a day number");
|
||||||
days[day - 1]().expect("error running day specified");
|
days[day - 1]().unwrap_or_else(|e| eprintln!("error running day specified: {}", e));
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
for (i, day) in days.iter().enumerate() {
|
for (i, day) in days.iter().enumerate() {
|
||||||
let i = i + 1;
|
let i = i + 1;
|
||||||
println!("day{}: ", i);
|
println!("day{}: ", i);
|
||||||
day().unwrap_or_else(|e| panic!("error running day {}: {}", i, e));
|
day().unwrap_or_else(|e| eprintln!("error running day {}: {}", i, e));
|
||||||
println!();
|
println!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue