chore: easing Display bound on FromServerFnError, #3811 follow-up

This commit is contained in:
Saber Haj Rabiee
2025-04-14 23:52:02 -07:00
parent e0bf5ec480
commit 6d5ab73594
2 changed files with 7 additions and 6 deletions

View File

@@ -201,14 +201,17 @@ pub mod browser {
Ok(message) => Ok(Message::Bytes(message.into())),
Err(err) => {
let err = InputStreamError::de(err);
let formatted_err = format!("{:?}", err);
web_sys::console::error_1(
&js_sys::JsString::from(err.to_string()),
&js_sys::JsString::from(
formatted_err.clone(),
),
);
const CLOSE_CODE_ERROR: u16 = 1011;
Err(WebSocketError::ConnectionClose(
CloseEvent {
code: CLOSE_CODE_ERROR,
reason: err.to_string(),
reason: formatted_err,
was_clean: true,
},
))
@@ -303,7 +306,7 @@ pub mod reqwest {
Err(err) => {
let err = E::de(err);
Err(tokio_tungstenite::tungstenite::Error::Io(
std::io::Error::other(err.to_string()),
std::io::Error::other(format!("{:?}", err)),
))
}
}

View File

@@ -561,9 +561,7 @@ impl<E: FromServerFnError> FromStr for ServerFnErrorWrapper<E> {
}
/// A trait for types that can be returned from a server function.
pub trait FromServerFnError:
std::fmt::Debug + Sized + Display + 'static
{
pub trait FromServerFnError: std::fmt::Debug + Sized + 'static {
/// The encoding strategy used to serialize and deserialize this error type. Must implement the [`Encodes`](server_fn::Encodes) trait for references to the error type.
type Encoder: Encodes<Self> + Decodes<Self>;