use std::io;

use proc_macro2::Span;
use syn::Ident;

#[derive(Debug, thiserror::Error)]
pub enum Error {
    #[error("{0}")]
    IoError(#[from] io::Error),

    #[error("{1:?}: Incorrectly constructed type: {0}")]
    TypeError(String, Span),
    #[error("{0:?}: Unhandled type name")]
    UnhandledTypeNameError(Ident),
    #[error("{0:?}: Only primitive types are allowed inside newtype X(Y) constructs")]
    UnhandledNonPrimitive(Span),

    #[error("{0}")]
    LexError(#[from] proc_macro2::LexError),
    #[error("{0}")]
    ParseError(#[from] syn::parse::Error),
}
