macro_rules! debug_unreachable (
($message:expr) => {
{
#[cfg(debug_assertions)]
{
$crate::report::system_panic!($message);
}
#[allow(unreachable_code)]
::std::hint::unreachable_unchecked()
}
};
($message:expr, $($args:tt)*) => {
$crate::report::debug_unreachable!(::std::format!($message, $($args)*))
};
);
macro_rules! system_panic (
($message:expr) => {{
#[cfg(not(target_family = "wasm"))]
{
let std_error = ::std::io::stderr();
let mut handle = std_error.lock();
let message = $crate::report::error_message!($message);
let _ = ::std::io::Write::write(
&mut handle,
::std::ops::Deref::deref(&message).as_bytes(),
);
let _ = ::std::io::Write::flush(&mut handle);
::std::process::abort();
}
#[cfg(target_family = "wasm")]
{
let message = $crate::report::error_message!($message);
::std::panic!("{}", message);
}
}};
($message:expr, $($args:tt)*) => {
$crate::report::system_panic!(::std::format!($message, $($args)*))
};
);
macro_rules! error_message (
($message:expr) => {
::std::format!(
r#" !! AD ASTRA INTERNAL ERROR
!!
!! This is a bug.
!! If you see this message, please open an Issue: https://github.com/Eliah-Lakhin/ad-astra/issues
!!
!! Message: {}
!! File: {}
!! Line: {}
!! Column: {}
"#,
$message,
::std::panic::Location::caller().file(),
::std::panic::Location::caller().line(),
::std::panic::Location::caller().column(),
)
};
($message:expr, $($args:tt)*) => {
$crate::report::error_message!(::std::format!($message, $($args)*))
};
);
pub(crate) use debug_unreachable;
pub(crate) use error_message;
pub(crate) use system_panic;