@@ -10,9 +10,9 @@ use application::Application;
11use std::path::PathBuf;
11use std::path::PathBuf;
13−use anyhow::Error;
13+use anyhow::{Context, Result};
15−fn setup_logging(verbosity: u64) -> Result<(), fern::InitError> {
15+fn setup_logging(verbosity: u64) -> Result<()> {
16 let mut base_config = fern::Dispatch::new();
16 let mut base_config = fern::Dispatch::new();
18 // Let's say we depend on something which whose "info" level messages are too
18 // Let's say we depend on something which whose "info" level messages are too
@@ -27,7 +27,7 @@ fn setup_logging(verbosity: u64) -> Result<(), fern::InitError> {
27 _3_or_more => base_config.level(log::LevelFilter::Trace),
27 _3_or_more => base_config.level(log::LevelFilter::Trace),
30− let home = dirs_next::home_dir().expect("can't find the home directory");
30+ let home = dirs_next::home_dir().context("can't find the home directory")?;
32 // Separate file config so we can include year, month and day in file logs
32 // Separate file config so we can include year, month and day in file logs
33 let file_config = fern::Dispatch::new()
33 let file_config = fern::Dispatch::new()
@@ -51,7 +51,7 @@ pub struct Args {
51 files: Vec<PathBuf>,
51 files: Vec<PathBuf>,
54−fn main() {
54+fn main() -> Result<()> {
55 let help = format!(
55 let help = format!(
@@ -89,7 +89,7 @@ FLAGS:
89 verbosity = 1;
89 verbosity = 1;
92− setup_logging(verbosity).expect("failed to initialize logging.");
92+ setup_logging(verbosity).context("failed to initialize logging")?;
94 let args = Args {
94 let args = Args {
95 files: pargs.finish().into_iter().map(|arg| arg.into()).collect(),
95 files: pargs.finish().into_iter().map(|arg| arg.into()).collect(),
@@ -105,17 +105,16 @@ FLAGS:
105 .as_deref()
105 .as_deref()
106 .unwrap_or(include_bytes!("../../languages.toml"));
106 .unwrap_or(include_bytes!("../../languages.toml"));
108− LOADER.get_or_init(|| {
109− let config = toml::from_slice(toml).expect("Could not parse languages.toml");
108+ let config = toml::from_slice(toml).context("Could not parse languages.toml")?;
110− Loader::new(config)
109+ LOADER.get_or_init(|| Loader::new(config));
113− let runtime = tokio::runtime::Runtime::new().unwrap();
111+ let runtime = tokio::runtime::Runtime::new().context("unable to start tokio runtime")?;
115 // TODO: use the thread local executor to spawn the application task separately from the work pool
113 // TODO: use the thread local executor to spawn the application task separately from the work pool
114+ let mut app = Application::new(args).context("unable to create new appliction")?;
116 runtime.block_on(async move {
115 runtime.block_on(async move {
117− let mut app = Application::new(args).unwrap();
119 app.run().await;
116 app.run().await;