diff --git a/integrations/actix/src/lib.rs b/integrations/actix/src/lib.rs index 0c311d223..879d920be 100644 --- a/integrations/actix/src/lib.rs +++ b/integrations/actix/src/lib.rs @@ -292,7 +292,12 @@ pub fn handle_server_fns_with_context( } else { HttpResponse::BadRequest().body(format!( "Could not find a server function at the route {:?}. \ - \n\nIt's likely that you need to call \ + \n\nIt's likely that either + 1. The API prefix you specify in the `#[server]` \ + macro doesn't match the prefix at which your server \ + function handler is mounted, or \n2. You are on a \ + platform that doesn't support automatic server \ + function registration and you need to call \ ServerFn::register_explicit() on the server function \ type, somewhere in your `main` function.", req.path() diff --git a/integrations/axum/src/lib.rs b/integrations/axum/src/lib.rs index 8cc9cebd7..716c35bb5 100644 --- a/integrations/axum/src/lib.rs +++ b/integrations/axum/src/lib.rs @@ -335,9 +335,14 @@ async fn handle_server_fns_inner( Response::builder().status(StatusCode::BAD_REQUEST).body( Full::from(format!( "Could not find a server function at the route \ - {fn_name}. \n\nIt's likely that you need to call \ + {fn_name}. \n\nIt's likely that either + 1. The API prefix you specify in the `#[server]` \ + macro doesn't match the prefix at which your server \ + function handler is mounted, or \n2. You are on a \ + platform that doesn't support automatic server \ + function registration and you need to call \ ServerFn::register_explicit() on the server function \ - type, somewhere in your `main` function." + type, somewhere in your `main` function.", )), ) } diff --git a/integrations/viz/src/lib.rs b/integrations/viz/src/lib.rs index 13eb24f52..9de53a0f5 100644 --- a/integrations/viz/src/lib.rs +++ b/integrations/viz/src/lib.rs @@ -312,10 +312,17 @@ async fn handle_server_fns_inner( .body(Body::from(format!( "Could not find a server function at the \ route {fn_name}. \n\nIt's likely that \ - you need to call \ + either + 1. The API prefix you specify in the \ + `#[server]` macro doesn't match the \ + prefix at which your server function \ + handler is mounted, or \n2. You are on a \ + platform that doesn't support automatic \ + server function registration and you \ + need to call \ ServerFn::register_explicit() on the \ server function type, somewhere in your \ - `main` function." + `main` function.", ))) } .expect("could not build Response"); diff --git a/server_fn/src/lib.rs b/server_fn/src/lib.rs index 35752c792..0d9831c18 100644 --- a/server_fn/src/lib.rs +++ b/server_fn/src/lib.rs @@ -608,6 +608,12 @@ where #[cfg(not(target_arch = "wasm32"))] let binary = binary.as_ref(); + if status == 400 { + return Err(ServerFnError::ServerError( + "No server function was found at this URL.".to_string(), + )); + } + ciborium::de::from_reader(binary) .map_err(|e| ServerFnError::Deserialization(e.to_string())) } else { @@ -616,6 +622,10 @@ where .await .map_err(|e| ServerFnError::Deserialization(e.to_string()))?; + if status == 400 { + return Err(ServerFnError::ServerError(text)); + } + let mut deserializer = JSONDeserializer::from_str(&text); T::deserialize(&mut deserializer) .map_err(|e| ServerFnError::Deserialization(e.to_string()))