Any ? operator in the server function might inadvertently expose sensitive error messages from the server side because the From is implemented for ServerFnError which uses error.to_string().
Functions that return anyhow::Error are cumbersome to use because they need explicit conversion (e.g., using the server_fn_error! macro).
It's difficult to share structured error types between server and client because ServerFnError has its own serialization strategy utilizing FromStr and Display.
Feature Request
Allow users to specify any error type for the server fn result where E: Serialize + DeserializeOwned + From<ServerFnError> + Debug + Display + Error. This could also require AsRef<ServerFnError> if Dioxus internally needs to identify the error kind on the client side. Since the ServerFnError itself satisfies these bounds, this change would be backward-compatible with the existing signature. However, I'd like to remove the ServerFnError::WrappedServerError and the corresponding generics field from it.
This feature would give users full control over From, Serialize, and Deserialize implementations for their error types and addresses the issues outlined above.
Implement Suggestion
Fork the server_fn_macro into the packages/server_macro and customize it as necessary.
Questions
Is there a strong rationale for continuing to use Leptos's server_fn_macro, or would maintaining a Dioxus-specific macro be more beneficial?
Problems
?
operator in the server function might inadvertently expose sensitive error messages from the server side because the FromServerFnError
which useserror.to_string()
.anyhow::Error
are cumbersome to use because they need explicit conversion (e.g., using theserver_fn_error!
macro).ServerFnError
has its own serialization strategy utilizingFromStr
andDisplay
.Feature Request
Allow users to specify any error type for the server fn result where
E: Serialize + DeserializeOwned + From<ServerFnError> + Debug + Display + Error
. This could also requireAsRef<ServerFnError>
if Dioxus internally needs to identify the error kind on the client side. Since theServerFnError
itself satisfies these bounds, this change would be backward-compatible with the existing signature. However, I'd like to remove theServerFnError::WrappedServerError
and the corresponding generics field from it.This feature would give users full control over
From
,Serialize
, andDeserialize
implementations for their error types and addresses the issues outlined above.Implement Suggestion
Fork the server_fn_macro into the packages/server_macro and customize it as necessary.
Questions