use std::sync::Arc;
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct PythonException {
data: Arc<ExceptionData>,
}
#[derive(Debug, PartialEq, Eq)]
struct ExceptionData {
type_name: Arc<str>,
message: Arc<str>,
is_value_error: bool,
}
const _: () = crate::send_sync::<PythonException>();
impl PythonException {
#[must_use]
pub fn new(type_name: Arc<str>, message: Arc<str>, is_value_error: bool) -> Self {
Self {
data: Arc::new(ExceptionData {
type_name,
message,
is_value_error,
}),
}
}
#[must_use]
pub fn as_str(&self) -> &str {
&self.data.type_name
}
#[must_use]
pub fn message(&self) -> &str {
&self.data.message
}
#[must_use]
pub fn is_value_error(&self) -> bool {
self.data.is_value_error
}
}