pub struct ExceptionInfo {
pub class_name: String,
pub message: Option<String>,
pub code: i64,
pub file: Option<String>,
pub line: u32,
}Available on crate feature
observer only.Expand description
Information about a PHP exception passed to observers.
Fields§
§class_name: StringThe exception class name (e.g., “Exception”, “RuntimeException”).
message: Option<String>The exception message.
code: i64The exception code.
file: Option<String>Source filename where the exception was thrown.
line: u32Line number where the exception was thrown.
Implementations§
Source§impl ExceptionInfo
impl ExceptionInfo
Sourcepub fn backtrace(&self) -> Option<Vec<BacktraceFrame>>
pub fn backtrace(&self) -> Option<Vec<BacktraceFrame>>
Captures the current PHP call stack at exception throw time.
This is lazy - only captures when called, zero cost if unused.
Returns None if no execution context is available.
§Example
ⓘ
fn on_exception(&self, exception: &ExceptionInfo) {
if let Some(trace) = exception.backtrace() {
for frame in trace {
eprintln!(" at {}:{} in {}",
frame.file.as_deref().unwrap_or("<internal>"),
frame.line,
frame.function.as_deref().unwrap_or("<main>")
);
}
}
}Trait Implementations§
Auto Trait Implementations§
impl Forget for ExceptionInfo
impl Freeze for ExceptionInfo
impl Move for ExceptionInfo
impl RefUnwindSafe for ExceptionInfo
impl Send for ExceptionInfowhere
RawVecInner: Send,
impl Sync for ExceptionInfowhere
RawVecInner: Sync,
impl Unpin for ExceptionInfo
impl UnsafeUnpin for ExceptionInfo
impl UnwindSafe for ExceptionInfowhere
RawVecInner: UnwindSafe,
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
Mutably borrows from an owned value. Read more