diff --git a/boa_engine/src/error.rs b/boa_engine/src/error.rs index 280449d076a..d85e40674fc 100644 --- a/boa_engine/src/error.rs +++ b/boa_engine/src/error.rs @@ -417,7 +417,7 @@ impl std::fmt::Display for JsError { /// /// assert_eq!(native_error.message(), "cannot decode uri"); /// ``` -#[derive(Debug, Clone, Trace, Finalize, Error)] +#[derive(Clone, Trace, Finalize, Error)] #[error("{kind}: {message}")] pub struct JsNativeError { /// The kind of native error (e.g. `TypeError`, `SyntaxError`, etc.) @@ -428,6 +428,16 @@ pub struct JsNativeError { realm: Option, } +impl std::fmt::Debug for JsNativeError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("JsNativeError") + .field("kind", &self.kind) + .field("message", &self.message) + .field("cause", &self.cause) + .finish_non_exhaustive() + } +} + impl JsNativeError { /// Creates a new `JsNativeError` from its `kind`, `message` and (optionally) its `cause`. fn new(kind: JsNativeErrorKind, message: Box, cause: Option>) -> Self { diff --git a/boa_engine/src/realm.rs b/boa_engine/src/realm.rs index 4a6f4104816..22b4d5c4d6d 100644 --- a/boa_engine/src/realm.rs +++ b/boa_engine/src/realm.rs @@ -6,6 +6,8 @@ //! //! A realm is represented in this implementation as a Realm struct with the fields specified from the spec. +use std::fmt; + use crate::{ context::{intrinsics::Intrinsics, HostHooks}, environments::DeclarativeEnvironment, @@ -17,18 +19,29 @@ use boa_profiler::Profiler; /// Representation of a Realm. /// /// In the specification these are called Realm Records. -#[derive(Clone, Debug, Trace, Finalize)] +#[derive(Clone, Trace, Finalize)] pub struct Realm { inner: Gc, } +impl fmt::Debug for Realm { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Realm") + .field("intrinsics", &self.inner.intrinsics) + .field("environment", &self.inner.environment) + .field("global_object", &self.inner.global_object) + .field("global_this", &self.inner.global_this) + .finish() + } +} + impl PartialEq for Realm { fn eq(&self, other: &Self) -> bool { std::ptr::eq(&*self.inner, &*other.inner) } } -#[derive(Debug, Trace, Finalize)] +#[derive(Trace, Finalize)] struct Inner { intrinsics: Intrinsics, environment: Gc,