#[non_exhaustive]pub enum InterpreterError {
Show 13 variants
Syntax(String),
Security(String),
Runtime(String),
LimitExceeded(String),
RecursionLimitExceeded {
limit: u32,
},
Tool {
tool_name: String,
message: String,
},
NameError(String),
TypeError(String),
ValueError(String),
AttributeError(String),
AssertionError(String),
PythonException {
type_name: String,
message: String,
},
StateFormatSuperseded {
found: u32,
expected: u32,
},
}Expand description
Errors surfaced to the host (consumer of the interpreter).
All error variants carry a human-readable message. The variant determines
the category of failure. Use pattern matching or Display for error reporting.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Syntax(String)
CPython-shaped prefix: SyntaxError: <msg>.
Security(String)
Sandbox-specific (no CPython equivalent — CPython doesn’t have a generic “security” rejection). Kept as-is so the prefix is recognisable as sandbox enforcement rather than a language-level error.
Runtime(String)
CPython prefix: RuntimeError: <msg>.
LimitExceeded(String)
Sandbox-specific (CPython has no operation-counter limit). Kept as-is.
RecursionLimitExceeded
CPython: RecursionError: maximum recursion depth exceeded.
Distinct from LimitExceeded so callers can recognise the
Python-equivalent and hint at sys.setrecursionlimit-style
mitigations instead of memory exhaustion.
Tool
Sandbox-specific (CPython has no tool concept).
NameError(String)
CPython prefix: NameError: <message>. The inner String is
the full message body (typically name 'X' is not defined),
NOT just the variable name — that lets stamp_line append a
line marker at the end of the rendered output instead of
inside the quoted name. Use Self::name_not_defined to
construct the common form.
TypeError(String)
CPython prefix: TypeError: <msg>.
ValueError(String)
CPython prefix: ValueError: <msg>.
AttributeError(String)
CPython prefix: AttributeError: <msg>.
AssertionError(String)
CPython prefix: AssertionError: <msg> (or AssertionError
alone when the assert had no message). Inner String includes
the message verbatim — empty when none.
PythonException
Raised-from-Python exceptions: <type_name>: <message>. Already
CPython-shape since the type_name is the exception class.
StateFormatSuperseded
Imported state blob carries a STATE_FORMAT_VERSION the current
interpreter no longer understands. The interpreter never silently
migrates across format versions — pre-versioning blobs (no version
prefix) are reported as found = 0, and any other mismatch surfaces
the exact version found vs the version expected.
Do not feed the blob into a newer interpreter shape; restart the host workflow from a clean initial state instead.
Implementations§
Source§impl InterpreterError
impl InterpreterError
Sourcepub fn name_not_defined(name: impl AsRef<str>) -> Self
pub fn name_not_defined(name: impl AsRef<str>) -> Self
Build the canonical name 'X' is not defined NameError body.
The inner String is the FULL message (matches CPython’s
NameError: name '<n>' is not defined); callers that produce
the rare other-body NameError can wrap their own String
directly in Self::NameError(...).
Trait Implementations§
Source§impl Clone for InterpreterError
impl Clone for InterpreterError
Source§fn clone(&self) -> InterpreterError
fn clone(&self) -> InterpreterError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for InterpreterError
impl Debug for InterpreterError
Source§impl Display for InterpreterError
impl Display for InterpreterError
Source§impl Error for InterpreterError
impl Error for InterpreterError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for InterpreterError
impl RefUnwindSafe for InterpreterError
impl Send for InterpreterError
impl Sync for InterpreterError
impl Unpin for InterpreterError
impl UnsafeUnpin for InterpreterError
impl UnwindSafe for InterpreterError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more