freenet-core
freenet-core copied to clipboard
Improve client_api::Error enum in stdlib
This should be improved, eg. OtherError's parameter should probably be a string rather than a boxed error, why does ConnectionError take a serde value, etc.
#[derive(thiserror::Error, Debug)]
#[non_exhaustive]
pub enum Error {
#[error(transparent)]
Deserialization(#[from] bincode::Error),
#[error("channel closed")]
ChannelClosed,
#[cfg(all(any(unix, windows), feature = "net"))]
#[error(transparent)]
ConnectionError(#[from] tokio_tungstenite::tungstenite::Error),
#[cfg(all(target_family = "wasm", feature = "net"))]
#[error("request error: {0}")]
ConnectionError(serde_json::Value),
#[error("connection closed")]
ConnectionClosed,
#[error("unhandled error: {0}")]
OtherError(Box<dyn std::error::Error + Send + Sync>),
}
why does ConnectionError take a serde value
cause websys returns jsons as errors basically and is what is being used under wasm target
OtherError's parameter should probably be a string rather than a boxed error
Not necesarely since a boxed error contains more information (e.g. possibly backtraces)
Ok, will close.
🤖 Relabeled for consistency
Applied labels:
T-enhancementP-mediumE-mediumA-developer-xp
Reasoning: The report requests improvements to the client_api::Error enum (types and consistency), which is an enhancement rather than a bug. Changing error variants and their payload types will likely require updating call sites, so it is moderate effort. This primarily affects developer experience and the stdlib API, so A-developer-xp is appropriate.
Previous labels: A-developer-xp,T-enhancement