-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Reorganize error modules and add HasAsyncErrorType * Add CanWrapError trait * Implement RaiseFrom * Implement DebugError and DisplayError * Implement RaiseInfallible and ReturnError * Implement PanicOnError * Implement DiscardDetail * Add #![no_std] to all crates * Use no_std for cgp-component-macro-lib * Add cgp-error-anyhow crate * Reorganize anyhow impls * Reorganize cgp-error-eyre * Reorganize cgp-error-std * Import from cgp_error::traits * Add changelog * Fix documentation
- Loading branch information
1 parent
9a79e8e
commit 7476276
Showing
70 changed files
with
509 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#![no_std] | ||
|
||
pub mod traits; | ||
|
||
pub use traits::{Async, MaybeSend, MaybeStatic, MaybeSync}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
crates/cgp-component-macro-lib/src/delegate_components/impl_delegate.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
crates/cgp-component-macro-lib/src/derive_component/component_spec.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
use alloc::format; | ||
use proc_macro2::Span; | ||
use quote::ToTokens; | ||
use syn::parse::{Parse, ParseStream}; | ||
|
2 changes: 2 additions & 0 deletions
2
crates/cgp-component-macro-lib/src/derive_component/consumer_impl.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
crates/cgp-component-macro-lib/src/derive_component/delegate_fn.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
crates/cgp-component-macro-lib/src/derive_component/provider_impl.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
crates/cgp-component-macro-lib/src/derive_component/provider_trait.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
use alloc::vec::Vec; | ||
use syn::punctuated::Punctuated; | ||
use syn::{parse_quote, Ident, ItemTrait, TraitItem}; | ||
|
||
|
1 change: 1 addition & 0 deletions
1
crates/cgp-component-macro-lib/src/derive_component/replace_self_type.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
crates/cgp-component-macro-lib/src/derive_component/snake_case.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
use alloc::string::{String, ToString}; | ||
use proc_macro2::Span; | ||
use syn::Ident; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#![no_std] | ||
|
||
/*! | ||
This crate provides the proc macros used for defining CGP components. | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[package] | ||
name = "cgp-error-anyhow" | ||
version = "0.2.0" | ||
edition = { workspace = true } | ||
license = { workspace = true } | ||
repository = { workspace = true } | ||
authors = { workspace = true } | ||
rust-version = { workspace = true } | ||
keywords = { workspace = true } | ||
description = """ | ||
Context-generic programming error handlers implemented using eyre | ||
""" | ||
|
||
[dependencies] | ||
cgp-core = { version = "0.2.0", default-features = false } | ||
anyhow = { version = "1.0.95", default-features = false } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use core::fmt::Debug; | ||
|
||
use anyhow::{anyhow, Error}; | ||
use cgp_core::error::ErrorRaiser; | ||
use cgp_core::prelude::*; | ||
|
||
pub struct DebugAnyhowError; | ||
|
||
impl<Context, E> ErrorRaiser<Context, E> for DebugAnyhowError | ||
where | ||
Context: HasErrorType<Error = Error>, | ||
E: Debug, | ||
{ | ||
fn raise_error(e: E) -> Error { | ||
anyhow!("{:?}", e) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use core::fmt::Display; | ||
|
||
use anyhow::{anyhow, Error}; | ||
use cgp_core::error::ErrorRaiser; | ||
use cgp_core::prelude::*; | ||
|
||
pub struct DisplayAnyhowError; | ||
|
||
impl<Context, E> ErrorRaiser<Context, E> for DisplayAnyhowError | ||
where | ||
Context: HasErrorType<Error = Error>, | ||
E: Display, | ||
{ | ||
fn raise_error(e: E) -> Error { | ||
anyhow!("{e}") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
pub mod debug_error; | ||
pub mod display_error; | ||
pub mod raise_anyhow_error; | ||
pub mod use_anyhow_error; | ||
|
||
pub use debug_error::*; | ||
pub use display_error::*; | ||
pub use raise_anyhow_error::*; | ||
pub use use_anyhow_error::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use core::error::Error as StdError; | ||
|
||
use anyhow::Error; | ||
use cgp_core::error::ErrorRaiser; | ||
use cgp_core::prelude::*; | ||
|
||
pub struct RaiseAnyhowError; | ||
|
||
impl<Context, E> ErrorRaiser<Context, E> for RaiseAnyhowError | ||
where | ||
Context: HasErrorType<Error = Error>, | ||
E: StdError + Send + Sync + 'static, | ||
{ | ||
fn raise_error(e: E) -> Error { | ||
e.into() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use anyhow::Error; | ||
use cgp_core::error::ProvideErrorType; | ||
|
||
pub struct UseAnyhowError; | ||
|
||
impl<Context> ProvideErrorType<Context> for UseAnyhowError { | ||
type Error = Error; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#![no_std] | ||
|
||
pub mod impls; | ||
|
||
pub use impls::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use core::fmt::Debug; | ||
|
||
use cgp_core::error::ErrorRaiser; | ||
use cgp_core::prelude::*; | ||
use eyre::{eyre, Error}; | ||
|
||
pub struct DebugEyreError; | ||
|
||
impl<Context, E> ErrorRaiser<Context, E> for DebugEyreError | ||
where | ||
Context: HasErrorType<Error = Error>, | ||
E: Debug, | ||
{ | ||
fn raise_error(e: E) -> Error { | ||
eyre!("{:?}", e) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use core::fmt::Display; | ||
|
||
use cgp_core::error::ErrorRaiser; | ||
use cgp_core::prelude::*; | ||
use eyre::{eyre, Error}; | ||
|
||
pub struct DisplayEyreError; | ||
|
||
impl<Context, E> ErrorRaiser<Context, E> for DisplayEyreError | ||
where | ||
Context: HasErrorType<Error = Error>, | ||
E: Display, | ||
{ | ||
fn raise_error(e: E) -> Error { | ||
eyre!("{e}") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
pub mod debug_error; | ||
pub mod display_error; | ||
pub mod raise_eyre_error; | ||
pub mod use_eyre_error; | ||
|
||
pub use debug_error::*; | ||
pub use display_error::*; | ||
pub use raise_eyre_error::*; | ||
pub use use_eyre_error::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use core::error::Error as StdError; | ||
|
||
use cgp_core::error::ErrorRaiser; | ||
use cgp_core::prelude::*; | ||
use eyre::Error; | ||
|
||
pub struct RaiseEyreError; | ||
|
||
impl<Context, E> ErrorRaiser<Context, E> for RaiseEyreError | ||
where | ||
Context: HasErrorType<Error = Error>, | ||
E: StdError + Send + Sync + 'static, | ||
{ | ||
fn raise_error(e: E) -> Error { | ||
e.into() | ||
} | ||
} |
Oops, something went wrong.