kodept_macros/error/
compiler_crash.rs1use std::any::Any;
2
3use codespan_reporting::diagnostic::Severity;
4use derive_more::Constructor;
5
6use crate::error::report::ReportMessage;
7
8#[derive(Constructor)]
9pub struct CompilerCrash {
10 message: Box<dyn Any + Send>,
11}
12
13impl From<CompilerCrash> for ReportMessage {
14 fn from(value: CompilerCrash) -> Self {
15 let message: String = if let Some(s) = value.message.downcast_ref::<String>() {
16 s.clone()
17 } else if let Some(s) = value.message.downcast_ref::<&str>() {
18 s.to_string()
19 } else {
20 "Unknown panic happened".to_string()
21 };
22 ReportMessage::new(Severity::Bug, "KC666", message)
23 }
24}