feat(diagnostics): preserve Registry and resource fault context for PLN-0176 step 28
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
use prometeu_bytecode::TrapInfo;
|
||||
use prometeu_vm::VmInitError;
|
||||
use std::fmt;
|
||||
mod init_diagnostic;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum CrashReport {
|
||||
@@ -10,6 +11,20 @@ pub enum CrashReport {
|
||||
}
|
||||
|
||||
impl CrashReport {
|
||||
/// The same machine fields serve headless and desktop transports.
|
||||
pub fn init_diagnostic(&self) -> Option<serde_json::Value> {
|
||||
match self {
|
||||
Self::VmInit { error } => Some(init_diagnostic::serialize(error)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
pub fn resource_failure(&self) -> Option<prometeu_bytecode::ResourceFailure> {
|
||||
match self {
|
||||
Self::VmTrap { trap } => trap.resource,
|
||||
Self::VmInit { error: VmInitError::RuntimeResourceLimit(resource) } => Some(*resource),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
pub fn kind(&self) -> &'static str {
|
||||
match self {
|
||||
Self::VmTrap { .. } => "vm_trap",
|
||||
|
||||
Reference in New Issue
Block a user