ErrorBoundary SSR and serialization of errors to support hydration

This commit is contained in:
Greg Johnston
2024-04-17 21:29:14 -04:00
parent 851e1f73fd
commit 42b99dd912
16 changed files with 377 additions and 66 deletions

View File

@@ -1,6 +1,7 @@
use std::{
cell::RefCell,
error, fmt,
error,
fmt::{self, Display},
future::Future,
ops,
pin::Pin,
@@ -69,6 +70,18 @@ pub trait ErrorHook: Send + Sync {
#[derive(Debug, PartialEq, Eq, Hash, Clone, Default)]
pub struct ErrorId(usize);
impl Display for ErrorId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Display::fmt(&self.0, f)
}
}
impl From<usize> for ErrorId {
fn from(value: usize) -> Self {
Self(value)
}
}
thread_local! {
static ERROR_HOOK: RefCell<Option<Arc<dyn ErrorHook>>> = RefCell::new(None);
}