Skip to content

Commit

Permalink
Remove error module and clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrgn committed Jan 9, 2022
1 parent fd30775 commit 5262234
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 32 deletions.
23 changes: 0 additions & 23 deletions src/error.rs

This file was deleted.

4 changes: 2 additions & 2 deletions src/formatter.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//! Functions related to formatting and printing lines from a `Tokenizer`.

use crate::{extensions::FindFrom, types::LineType};

use log::debug;

use crate::{extensions::FindFrom, types::LineType};

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
/// Represents a snippet from a page of a specific highlighting class.
pub enum PageSnippet<'a> {
Expand Down
3 changes: 1 addition & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use pager::Pager;

mod cache;
mod config;
mod error;
pub mod extensions;
mod formatter;
mod line_iterator;
Expand Down Expand Up @@ -303,7 +302,7 @@ fn create_config_and_exit(enable_styles: bool) {
process::exit(0);
}
Err(e) => {
print_error(enable_styles, &e);
print_error(enable_styles, &e.context("Could not create seed config"));
process::exit(1);
}
}
Expand Down
11 changes: 6 additions & 5 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use std::{fmt, str};

use anyhow::{anyhow, Result};
use serde_derive::{Deserialize, Serialize};

#[derive(Debug, Eq, PartialEq, Copy, Clone, Serialize, Deserialize)]
Expand All @@ -26,15 +27,15 @@ impl fmt::Display for PlatformType {
}

impl str::FromStr for PlatformType {
type Err = String;
type Err = anyhow::Error;

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"linux" => Ok(Self::Linux),
"osx" | "macos" => Ok(Self::OsX),
"sunos" => Ok(Self::SunOs),
"windows" => Ok(Self::Windows),
other => Err(format!(
other => Err(anyhow!(
"Unknown OS: {}. Possible values: linux, macos, osx, sunos, windows",
other
)),
Expand Down Expand Up @@ -87,14 +88,14 @@ pub enum ColorOptions {
}

impl str::FromStr for ColorOptions {
type Err = String;
type Err = anyhow::Error;

fn from_str(s: &str) -> Result<Self, Self::Err> {
fn from_str(s: &str) -> Result<Self> {
match s {
"always" => Ok(Self::Always),
"auto" => Ok(Self::Auto),
"never" => Ok(Self::Never),
other => Err(format!(
other => Err(anyhow!(
"Unknown color option: {}. Possible values: always, auto, never",
other
)),
Expand Down

0 comments on commit 5262234

Please sign in to comment.