use crate::values::Value;
use dsntk_common::{DsntkError, ToErrorMessage};
#[derive(ToErrorMessage)]
struct TypesError(String);
pub fn err_invalid_feel_type_name(s: &str) -> DsntkError {
TypesError(format!("invalid FEEL type name: {s}")).into()
}
pub fn err_invalid_value_for_retrieving_using_feel_type(s1: &str, s2: &str) -> DsntkError {
TypesError(format!("invalid value for retrieving with type check, type = '{s1}', value = '{s2}'")).into()
}
#[derive(ToErrorMessage)]
struct ValueError(String);
pub fn err_invalid_xsd_integer(text: &str) -> DsntkError {
ValueError(format!("'{text}' is not valid xsd:integer representation")).into()
}
pub fn err_invalid_xsd_decimal(text: &str) -> DsntkError {
ValueError(format!("'{text}' is not valid xsd:decimal representation")).into()
}
pub fn err_invalid_xsd_double(text: &str) -> DsntkError {
ValueError(format!("'{text}' is not valid xsd:double representation")).into()
}
pub fn err_invalid_xsd_boolean(text: &str) -> DsntkError {
ValueError(format!("'{text}' is not valid xsd:boolean representation")).into()
}
pub fn err_invalid_xsd_date(text: &str) -> DsntkError {
ValueError(format!("'{text}' is not valid xsd:date representation")).into()
}
pub fn err_invalid_xsd_time(text: &str) -> DsntkError {
ValueError(format!("'{text}' is not valid xsd:time representation")).into()
}
pub fn err_invalid_xsd_date_time(text: &str) -> DsntkError {
ValueError(format!("'{text}' is not valid xsd:dateTime representation")).into()
}
pub fn err_invalid_xsd_duration(text: &str) -> DsntkError {
ValueError(format!("'{text}' is not valid xsd:duration representation")).into()
}
#[derive(ToErrorMessage)]
struct ContextError(String);
pub fn err_value_is_not_a_context(value: &Value) -> DsntkError {
ContextError(format!("'{value}' is not a value containing context")).into()
}
#[derive(ToErrorMessage)]
struct BifError(String);
pub fn err_unknown_function_name(name: &str) -> DsntkError {
BifError(format!("unknown built-in function name: {name}")).into()
}
#[derive(ToErrorMessage)]
struct DtoError(String);
pub fn err_invalid_attribute(description: &str) -> DsntkError {
DtoError(format!("invalid attribute: {description}")).into()
}
pub fn err_missing_attribute(name: &str) -> DsntkError {
DtoError(format!("missing attribute: {name}")).into()
}