rtimelogger 0.8.6

A simple cross-platform CLI tool to track working hours, lunch breaks, and calculate surplus time
Documentation
//! Unified application error type.
//! All modules (db, core, cli, utils) return AppError to keep the error
//! handling consistent and easy to manage.

use chrono::NaiveDate;
use std::io;
use thiserror::Error;

#[derive(Error, Debug)]
pub enum AppError {
    // ---------------------------
    // IO
    // ---------------------------
    #[error("I/O error: {0}")]
    Io(#[from] io::Error),

    // ---------------------------
    // Database-related
    // ---------------------------
    #[error("Database error: {0}")]
    Db(#[from] rusqlite::Error),

    #[error("Database migration error: {0}")]
    Migration(String),

    // ---------------------------
    // Parsing errors
    // ---------------------------
    #[error("Invalid date format: {0}")]
    InvalidDate(String),

    #[error("Invalid time format: {0}")]
    InvalidTime(String),

    #[error("Invalid position code: {0}")]
    InvalidPosition(String),

    #[error("Invalid event type: {0}")]
    InvalidEventType(String),

    #[error("Invalid operation mode: {0}")]
    InvalidOperation(String),

    #[error("Invalid date range: from ({from}) must be <= to ({to})\n")]
    InvalidDateRange { from: NaiveDate, to: NaiveDate },

    // ---------------------------
    // Logic errors
    // ---------------------------
    #[error("Invalid arguments: {0}\n")]
    InvalidArgs(String),

    #[error("No events found for date {0}")]
    NoEventsForDate(String),

    #[error("Invalid pair index: {0}")]
    InvalidPair(usize),

    #[error("Timeline error: {0}")]
    Timeline(String),

    #[error("Gap analysis error: {0}")]
    Gap(String),

    // ---------------------------
    // Config errors
    // ---------------------------
    #[error("Configuration error: {0}")]
    Config(String),

    #[error("Failed to load configuration")]
    ConfigLoad,

    #[error("Failed to save configuration")]
    ConfigSave,

    // ---------------------------
    // Export errors
    // ---------------------------
    #[error("Export format not supported: {0}")]
    InvalidExportFormat(String),

    #[error("Export error: {0}")]
    Export(String),

    // ---------------------------
    // Generic fallback
    // ---------------------------
    #[error("Internal error: {0}\nThis is likely a bug. Please report it to the developers.\n")]
    Other(String),
}

pub type AppResult<T> = Result<T, AppError>;