jobber 0.1.0-alpha

Minimalistic console work time tracker
use std::path::PathBuf;
use thiserror::Error;

use crate::entities;

#[derive(Debug, Error)]
pub(crate) enum Error {
    #[error("Cannot open database file '{0}' ({1})")]
    CannotOpenDatabase(PathBuf, std::io::Error),
    #[error("Cannot read database file '{0}' ({1})")]
    CannotReadDatabase(PathBuf, serde_json::error::Error),
    #[error("Cannot write database file '{0}' ({1})")]
    CannotWriteDatabase(PathBuf, serde_json::error::Error),
    #[error("{0}")]
    Database(#[from] crate::database::Error),
    #[error("{0}")]
    Io(#[from] std::io::Error),
    #[error("{0}")]
    Json(#[from] serde_json::Error),
    #[error("{0}")]
    Confy(#[from] confy::ConfyError),
    #[error("{0}")]
    Entities(#[from] entities::Error),
    #[error("{0}")]
    ParseIntError(#[from] std::num::ParseIntError),
    #[error("Cannot convert '{0}' into a date/time")]
    CannotConvertDateTime(String),
    #[error("No current job.")]
    NoCurrentJob,
    #[error("Current job {0} is deleted.")]
    CurrentJobDeleted(usize),
    #[error("Invalid time range: {0}..{1}")]
    InvalidRange(String, String),
    #[error("Invalid time range: {0}")]
    InvalidRangeEx(String),
    #[error("No jobs found in time range: {0}")]
    NoJobsFoundInRange(String),
    #[error("{0}")]
    Typst(#[from] typst_as_lib::TypstAsLibError),
    #[error("{0}")]
    TypstPDF(String),
    #[error("{0}")]
    Inquire(#[from] inquire::error::InquireError),
}

pub(crate) type Result<T> = std::result::Result<T, Error>;