summaryrefslogtreecommitdiffstats
path: root/src/bin
diff options
context:
space:
mode:
authorClement Tsang <34804052+ClementTsang@users.noreply.github.com>2020-08-31 23:59:33 -0400
committerGitHub <noreply@github.com>2020-08-31 23:59:33 -0400
commita4ddd649e140e1bc7cab29a53662d4f345f4f1ff (patch)
tree931e2614a77a7351eb7dc2fe6e9c1c734898dff0 /src/bin
parent5ed573157c00a0617c786edde0a241bd75e81666 (diff)
refactor: Update error messages w/ anyhow and thiserror (#216)
Refactoring and updating of error messages + tests to be more useful.
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/main.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/bin/main.rs b/src/bin/main.rs
index 95444491..7f8b9900 100644
--- a/src/bin/main.rs
+++ b/src/bin/main.rs
@@ -3,7 +3,7 @@
#[macro_use]
extern crate log;
-use bottom::{canvas, constants::*, data_conversion::*, options::*, utils::error, *};
+use bottom::{canvas, constants::*, data_conversion::*, options::*, *};
use std::{
boxed::Box,
@@ -17,6 +17,7 @@ use std::{
time::Duration,
};
+use anyhow::{Context, Result};
use crossterm::{
event::EnableMouseCapture,
execute,
@@ -24,18 +25,22 @@ use crossterm::{
};
use tui::{backend::CrosstermBackend, Terminal};
-fn main() -> error::Result<()> {
+fn main() -> Result<()> {
#[cfg(debug_assertions)]
{
utils::logging::init_logger()?;
}
let matches = clap::get_matches();
- let config: Config = create_config(matches.value_of("CONFIG_LOCATION"))?;
+ let config_path = read_config(matches.value_of("CONFIG_LOCATION"))
+ .context("Unable to access the given config file location.")?;
+ let config: Config = create_or_get_config(&config_path)
+ .context("Unable to properly parse or create the config file.")?;
// Get widget layout separately
let (widget_layout, default_widget_id, default_widget_type_option) =
- get_widget_layout(&matches, &config)?;
+ get_widget_layout(&matches, &config)
+ .context("Found an issue while trying to build the widget layout.")?;
// Create "app" struct, which will control most of the program and store settings/state
let mut app = build_app(