fix: Handle HTTP errors in FromResponseParts (#5243)
* fix: Handle HTTP errors in FromResponseParts Check for non-success status codes before attempting to decode response parts. For error responses, parse the JSON error payload and convert it to a ServerFnError::ServerError. Also make ErrorPayload fields pub(crate) to allow internal access. * fixed test name
This commit is contained in:
1 parent
7a7f5fb719
commit
ceb82612e0
2 files changed
+99
-7
No files matched your search
@@ -87,12 +87,12 @@ pub enum RestEndpointPayload<T, E> {
|
||||
/// The error payload structure for REST API errors.
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
|
||||
pub struct ErrorPayload<E> {
|
||||
message: String,
|
||||
pub(crate) message: String,
|
||||
|
||||
code: u16,
|
||||
pub(crate) code: u16,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
data: Option<E>,
|
||||
pub(crate) data: Option<E>,
|
||||
}
|
||||
|
||||
/// Convert a `RequestError` into a `ServerFnError`.
|
||||
|
||||
Reference in new issue
Block a user