use markerml_middleend::Span;
use miette::Diagnostic;
use thiserror::Error;
#[derive(Debug, Error, Diagnostic)]
pub enum BackendError {
#[error(transparent)]
#[diagnostic(transparent)]
RequiredDefaultPropertyMissing(#[from] RequiredDefaultPropertyMissingError),
#[error(transparent)]
#[diagnostic(transparent)]
TextMissing(#[from] TextMissingError),
#[error(transparent)]
#[diagnostic(transparent)]
TypeMismatch(#[from] TypeMismatchError),
#[error("Unimplemented")]
Unimplemented,
#[error("TODO")]
Todo,
}
#[derive(Debug, Error, Diagnostic)]
#[error("Required default property, also known as '{name}' is missing")]
pub struct RequiredDefaultPropertyMissingError {
pub name: String,
#[label("Component defined here")]
pub span: Span,
}
#[derive(Debug, Error, Diagnostic)]
#[error("Text is missing from the component")]
pub struct TextMissingError {
#[label("Component defined here")]
pub span: Span,
}
#[derive(Debug, Error, Diagnostic)]
#[error("Type mismatch. Expected '{expected}', got '{got}'")]
pub struct TypeMismatchError {
pub expected: &'static str,
pub got: &'static str,
#[label("Value defined here")]
pub span: Span,
}