rename any_error

This commit is contained in:
Greg Johnston 2024-04-27 11:08:10 -04:00
parent 09cc5df975
commit 272b6da00c
17 changed files with 32 additions and 32 deletions

View file

@ -45,7 +45,7 @@ version = "0.7.0-preview"
rust-version = "1.75"
[workspace.dependencies]
any_error = { path = "./any_error/", version = "0.1" }
throw_error = { path = "./any_error/", version = "0.1" }
any_spawner = { path = "./any_spawner/", version = "0.1" }
const_str_slice_concat = { path = "./const_str_slice_concat", version = "0.1" }
either_of = { path = "./either_of/" }

View file

@ -1,5 +1,5 @@
[package]
name = "any_error"
name = "throw_error"
edition = "2021"
version = "0.1.0"
authors = ["Greg Johnston"]

View file

@ -5,7 +5,7 @@ edition = "2021"
[dependencies]
leptos = { path = "../../leptos", features = ["csr"] }
any_error = { path = "../../any_error/" }
throw_error = { path = "../../any_error/" }
any_spawner = { path = "../../any_spawner/" }
next_tuple = { path = "../../next_tuple/" }
gtk = { version = "0.8.0", package = "gtk4", optional = true }

View file

@ -4,7 +4,7 @@ edition = "2021"
version.workspace = true
[dependencies]
any_error = { workspace = true }
throw_error = { workspace = true }
or_poisoned = { workspace = true }
futures = "0.3"
serde = { version = "1", features = ["derive"] }

View file

@ -46,14 +46,14 @@ impl SharedContext for CsrSharedContext {
fn errors(
&self,
_boundary_id: &SerializedDataId,
) -> Vec<(any_error::ErrorId, any_error::Error)> {
) -> Vec<(throw_error::ErrorId, throw_error::Error)> {
Vec::new()
}
#[inline(always)]
fn take_errors(
&self,
) -> Vec<(SerializedDataId, any_error::ErrorId, any_error::Error)> {
) -> Vec<(SerializedDataId, throw_error::ErrorId, throw_error::Error)> {
Vec::new()
}
@ -61,8 +61,8 @@ impl SharedContext for CsrSharedContext {
fn register_error(
&self,
_error_boundary: SerializedDataId,
_error_id: any_error::ErrorId,
_error: any_error::Error,
_error_id: throw_error::ErrorId,
_error: throw_error::Error,
) {
}

View file

@ -1,6 +1,5 @@
use super::{SerializedDataId, SharedContext};
use crate::{PinnedFuture, PinnedStream};
use any_error::{Error, ErrorId};
use core::fmt::Debug;
use js_sys::Array;
use once_cell::sync::Lazy;
@ -8,6 +7,7 @@ use std::{
fmt::Display,
sync::atomic::{AtomicBool, AtomicUsize, Ordering},
};
use throw_error::{Error, ErrorId};
use wasm_bindgen::{prelude::wasm_bindgen, JsCast};
#[wasm_bindgen]

View file

@ -18,7 +18,6 @@ mod csr;
#[cfg_attr(docsrs, doc(cfg(feature = "browser")))]
mod hydrate;
mod ssr;
use any_error::{Error, ErrorId};
#[cfg(feature = "browser")]
pub use csr::*;
use futures::Stream;
@ -27,6 +26,7 @@ pub use hydrate::*;
use serde::{Deserialize, Serialize};
pub use ssr::*;
use std::{fmt::Debug, future::Future, pin::Pin};
use throw_error::{Error, ErrorId};
/// Type alias for a boxed [`Future`].
pub type PinnedFuture<T> = Pin<Box<dyn Future<Output = T> + Send + Sync>>;

View file

@ -1,6 +1,5 @@
use super::{SerializedDataId, SharedContext};
use crate::{PinnedFuture, PinnedStream};
use any_error::{Error, ErrorId};
use futures::{
stream::{self, FuturesUnordered},
StreamExt,
@ -15,6 +14,7 @@ use std::{
Arc, RwLock,
},
};
use throw_error::{Error, ErrorId};
#[derive(Default)]
/// The shared context that should be used on the server side.

View file

@ -10,7 +10,7 @@ readme = "../README.md"
rust-version.workspace = true
[dependencies]
any_error = { workspace = true }
throw_error = { workspace = true }
any_spawner = { workspace = true, features = ["wasm-bindgen"] }
base64 = { version = "0.22", optional = true }
cfg-if = "1"

View file

@ -1,5 +1,4 @@
use crate::{children::TypedChildren, IntoView};
use any_error::{Error, ErrorHook, ErrorId};
use hydration_context::{SerializedDataId, SharedContext};
use leptos_macro::component;
use reactive_graph::{
@ -16,6 +15,7 @@ use tachys::{
ssr::StreamBuilder,
view::{Mountable, Position, PositionState, Render, RenderHtml},
};
use throw_error::{Error, ErrorHook, ErrorId};
///
/// ## Beginner's Tip: ErrorBoundary Requires Your Error To Implement std::error::Error.
@ -68,7 +68,7 @@ where
let hook = hook as Arc<dyn ErrorHook>;
// provide the error hook and render children
any_error::set_error_hook(Arc::clone(&hook));
throw_error::set_error_hook(Arc::clone(&hook));
let mut children = Some(children.into_inner()());
move || ErrorBoundaryView {
@ -343,7 +343,7 @@ impl ErrorHook for ErrorBoundaryErrorHook {
key
}
fn clear(&self, id: &any_error::ErrorId) {
fn clear(&self, id: &throw_error::ErrorId) {
self.errors.update(|map| {
map.remove(id);
});

View file

@ -168,7 +168,6 @@ mod show;
mod suspense_component;
pub mod text_prop;
mod transition;
pub use any_error as error;
pub use for_loop::*;
pub use hydration_scripts::*;
pub use leptos_macro::*;
@ -179,6 +178,7 @@ pub use reactive_graph::{
pub use server_fn;
pub use show::*;
pub use suspense_component::Suspense;
pub use throw_error as error;
pub use transition::*;
#[doc(hidden)]
pub use typed_builder;

View file

@ -3,7 +3,6 @@ use crate::{
into_view::View,
IntoView,
};
use any_error::ErrorHookFuture;
use any_spawner::Executor;
use futures::FutureExt;
use leptos_macro::component;
@ -33,6 +32,7 @@ use tachys::{
Mountable, Position, PositionState, Render, RenderHtml,
},
};
use throw_error::ErrorHookFuture;
/// TODO docs!
#[component]

View file

@ -10,7 +10,7 @@ readme = "../README.md"
rust-version.workspace = true
[dependencies]
any_error = { workspace = true }
throw_error = { workspace = true }
server_fn_macro_default = { workspace = true }
# used for hashing paths in #[server] macro
const_format = "0.2"

View file

@ -1,4 +1,3 @@
use any_error::Error;
use serde::{Deserialize, Serialize};
use std::{
error, fmt,
@ -8,6 +7,7 @@ use std::{
sync::Arc,
};
use thiserror::Error;
use throw_error::Error;
use url::Url;
/// A custom header that can be used to indicate a server function returned an error.

View file

@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"
[dependencies]
any_error = { workspace = true }
throw_error = { workspace = true }
any_spawner = { workspace = true }
const_str_slice_concat = { workspace = true }
either_of = { workspace = true }

View file

@ -9,13 +9,13 @@ use crate::{
RenderHtml, ToTemplate,
},
};
use any_error::Error as AnyError;
use reactive_graph::{
computed::ScopedFuture,
effect::RenderEffect,
graph::{Observer, ReactiveNode},
};
use std::future::{ready, Ready};
use throw_error::Error as AnyError;
mod class;
mod guards;
@ -377,7 +377,6 @@ mod stable {
ssr::StreamBuilder,
view::{Position, PositionState, Render, RenderHtml},
};
use any_error::Error as AnyError;
use reactive_graph::{
computed::{ArcMemo, Memo},
signal::{ArcReadSignal, ArcRwSignal, ReadSignal, RwSignal},
@ -385,6 +384,7 @@ mod stable {
wrappers::read::{ArcSignal, Signal},
};
use std::future::{ready, Ready};
use throw_error::Error as AnyError;
macro_rules! signal_impl {
($sig:ident) => {

View file

@ -5,7 +5,6 @@ use crate::{
ssr::StreamBuilder,
view::{Mountable, Render, Renderer},
};
use any_error::Error as AnyError;
use pin_project_lite::pin_project;
use std::{
future::{Future, Ready},
@ -13,6 +12,7 @@ use std::{
pin::Pin,
task::{Context, Poll},
};
use throw_error::Error as AnyError;
impl<R, T, E> Render<R> for Result<T, E>
where
@ -26,7 +26,7 @@ where
let placeholder = R::create_placeholder();
let state = match self {
Ok(view) => Ok(view.build()),
Err(e) => Err(any_error::throw(e.into())),
Err(e) => Err(throw_error::throw(e.into())),
};
ResultState { placeholder, state }
}
@ -35,7 +35,7 @@ where
match (&mut state.state, self) {
// both errors: throw the new error and replace
(Err(prev), Err(new)) => {
*prev = any_error::throw(new.into());
*prev = throw_error::throw(new.into());
}
// both Ok: need to rebuild child
(Ok(old), Ok(new)) => {
@ -44,11 +44,11 @@ where
// Ok => Err: unmount, replace with marker, and throw
(Ok(old), Err(err)) => {
old.unmount();
state.state = Err(any_error::throw(err));
state.state = Err(throw_error::throw(err));
}
// Err => Ok: clear error and build
(Err(err), Ok(new)) => {
any_error::clear(err);
throw_error::clear(err);
let mut new_state = new.build();
R::try_mount_before(&mut new_state, state.placeholder.as_ref());
state.state = Ok(new_state);
@ -66,7 +66,7 @@ where
/// Marks the location of this view.
placeholder: R::Placeholder,
/// The view state.
state: Result<T, any_error::ErrorId>,
state: Result<T, throw_error::ErrorId>,
}
impl<T, R> Drop for ResultState<T, R>
@ -78,7 +78,7 @@ where
// when the state is cleared, unregister this error; this item is being dropped and its
// error should no longer be shown
if let Err(e) = &self.state {
any_error::clear(e);
throw_error::clear(e);
}
}
}
@ -152,7 +152,7 @@ where
match self {
Ok(inner) => inner.to_html_with_buf(buf, position),
Err(e) => {
any_error::throw(e);
throw_error::throw(e);
}
}
}
@ -169,7 +169,7 @@ where
inner.to_html_async_with_buf::<OUT_OF_ORDER>(buf, position)
}
Err(e) => {
any_error::throw(e);
throw_error::throw(e);
}
}
}
@ -182,7 +182,7 @@ where
// hydrate the state, if it exists
let state = self
.map(|s| s.hydrate::<FROM_SERVER>(cursor, position))
.map_err(|e| any_error::throw(e.into()));
.map_err(|e| throw_error::throw(e.into()));
let placeholder = cursor.next_placeholder(position);