use std::{num::ParseFloatError, path::PathBuf, string::FromUtf8Error};
use thiserror::Error;
use super::renderer::RenderedTile;
#[derive(Error, Debug)]
pub enum Error {
#[error("crossbeam error")]
Crossbeam(#[from] crossbeam_channel::SendError<RenderedTile>),
#[error("image processing error")]
Image(#[from] image::ImageError),
#[error("the latitude is invalid")]
InvalidLatitude(#[source] ParseFloatError),
#[error("the longitude is invalid")]
InvalidLongitude(#[source] ParseFloatError),
#[error("the output directory is invalid")]
InvalidOutputDirectory,
#[error("error when {0} because of an underlying I/O error")]
Io(&'static str, #[source] std::io::Error),
#[error("input has no latitude value")]
MissingLatitude,
#[error("input has no longitude value")]
MissingLongitude,
#[error("output file {0} already exists")]
OutputAlreadyExists(PathBuf),
#[error("SQLite error")]
Sqlite(#[from] rusqlite::Error),
#[error("invalid utf8 input data")]
Utf8(#[from] FromUtf8Error),
#[error("XML parse error")]
Xml(#[from] roxmltree::Error),
}
pub type Result<T, E = Error> = std::result::Result<T, E>;