Skip to content

Commit

Permalink
fix(core): Set json content type for errors returned from commands (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianLars committed Mar 19, 2024
1 parent 75f5cb4 commit 81b853b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changes/fix-ipc-error-json.md
@@ -0,0 +1,5 @@
---
tauri: 'patch:bug'
---

Fixed an issue where errors where returned as strings instead of objects from commands.
4 changes: 2 additions & 2 deletions core/tauri/src/ipc/protocol.rs
Expand Up @@ -92,7 +92,7 @@ pub fn get<R: Runtime>(manager: Arc<AppManager<R>>, label: String) -> UriSchemeP
let mut response =
http::Response::new(serde_json::to_vec(&e.0).unwrap().into());
*response.status_mut() = StatusCode::BAD_REQUEST;
(response, mime::TEXT_PLAIN)
(response, mime::APPLICATION_JSON)
}
};

Expand Down Expand Up @@ -305,7 +305,7 @@ fn handle_ipc_message<R: Runtime>(message: String, manager: &AppManager<R>, labe
mime_type = match &response {
InvokeResponse::Ok(InvokeBody::Json(_)) => mime::APPLICATION_JSON,
InvokeResponse::Ok(InvokeBody::Raw(_)) => mime::APPLICATION_OCTET_STREAM,
InvokeResponse::Err(_) => mime::TEXT_PLAIN,
InvokeResponse::Err(_) => mime::APPLICATION_JSON,
}
.essence_str()
)
Expand Down

0 comments on commit 81b853b

Please sign in to comment.