use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[repr(u8)]
pub enum SsrErrorCode {
UnsafeAttrName = 65,
NoTeleportTarget = 66,
InvalidAstNode = 67,
}
impl SsrErrorCode {
pub fn message(&self) -> &'static str {
match self {
Self::UnsafeAttrName => "Unsafe attribute name for SSR.",
Self::NoTeleportTarget => "Missing required 'to' prop on <Teleport>.",
Self::InvalidAstNode => "Invalid AST node encountered during SSR transform.",
}
}
}
#[cfg(test)]
mod tests {
use super::SsrErrorCode;
#[test]
fn test_error_messages() {
assert!(!SsrErrorCode::UnsafeAttrName.message().is_empty());
assert!(!SsrErrorCode::NoTeleportTarget.message().is_empty());
assert!(!SsrErrorCode::InvalidAstNode.message().is_empty());
}
}