use std::io;
use image::ImageError;
use png::DecodingError;
use thiserror::Error;

#[derive(Error, Debug)]
pub enum GribError {
    #[error("i/o error")]
    IoError(#[from] io::Error),
    #[error("incorrect indicator: found {0}")]
    IncorrectIndicator(u32),
    #[error("incorrect edition: found {0}")]
    IncorrectEdition(u8),
    #[error("this library only supports global grids in table 3.1")]
    NonTable31,
    #[error("this library does not support reading octets 15-xx in section 3")]
    ListOfNumbersNotSupported,
    #[error("unsupported grid definition template {0}")]
    UnsupportedGrid(u16),
    #[error("unsupported product definition template {0}")]
    UnsupportedProductDefTmpl(u16),
    #[error("unsupported data representation template {0}")]
    UnsupportedDataRepresentationTemplate(u16),
    #[error("unsupported bitmap")]
    UnsupportedBitmap(u8),
    #[error("missing data representation")]
    MissingDataRepresentation,
    #[error("missing identification")]
    MissingIdentification,
    #[error("missing grid definition")]
    MissingGridDefinition,
    #[error("missing product definition")]
    MissingProductDefinition,
    #[error("missing bitmap")]
    MissingBitmap,
    #[error("missing data")]
    MissingData,
    #[error("image error")]
    PNGImageError(#[from] DecodingError),
    #[error("image error")]
    ImageError(#[from] ImageError)
}