hittekaart 0.2.0

Generates OSM heatmap tiles from GPX tracks
Documentation
//! Error definitions for hittekaart.
use std::{num::ParseFloatError, path::PathBuf, string::FromUtf8Error};

use thiserror::Error;

use super::renderer::RenderedTile;

/// Main error type. All hittekaart errors are mapped to this enum.
#[derive(Error, Debug)]
pub enum Error {
    /// Error for crossbeam operations.
    ///
    /// hittekaart uses multithreading internally to speed up tile generation. We use crossbeam to
    /// pass messages between threads.
    #[error("crossbeam error")]
    Crossbeam(#[from] crossbeam_channel::SendError<RenderedTile>),
    /// Underlying image processing error.
    #[error("image processing error")]
    Image(#[from] image::ImageError),
    /// The GPX file contains an invalid latitude value.
    #[error("the latitude is invalid")]
    InvalidLatitude(#[source] ParseFloatError),
    /// The GPX file contains an invalid longitude value.
    #[error("the longitude is invalid")]
    InvalidLongitude(#[source] ParseFloatError),
    /// The output directory is invalid.
    #[error("the output directory is invalid")]
    InvalidOutputDirectory,
    /// Underlying I/O error.
    ///
    /// The first field contains a description of the action that was executed when the error
    /// occurred.
    #[error("error when {0} because of an underlying I/O error")]
    Io(&'static str, #[source] std::io::Error),
    /// The input point had no latitude value attached.
    #[error("input has no latitude value")]
    MissingLatitude,
    /// The input point had no longitude value attached.
    #[error("input has no longitude value")]
    MissingLongitude,
    /// The output folder already exists.
    #[error("output file {0} already exists")]
    OutputAlreadyExists(PathBuf),
    /// Underlying SQLite error.
    #[error("SQLite error")]
    Sqlite(#[from] rusqlite::Error),
    /// UTF-8 decoding error.
    #[error("invalid utf8 input data")]
    Utf8(#[from] FromUtf8Error),
    /// XML parsing error.
    #[error("XML parse error")]
    Xml(#[from] roxmltree::Error),
}

/// Type alias that defaults to [`enum@Error`] as error variant.
pub type Result<T, E = Error> = std::result::Result<T, E>;