diff --git a/.changes/fix-ipc-error-json.md b/.changes/fix-ipc-error-json.md new file mode 100644 index 00000000000..2e5e5f75639 --- /dev/null +++ b/.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. diff --git a/core/tauri/src/ipc/protocol.rs b/core/tauri/src/ipc/protocol.rs index 6a407d64034..4b29c372b26 100644 --- a/core/tauri/src/ipc/protocol.rs +++ b/core/tauri/src/ipc/protocol.rs @@ -92,7 +92,7 @@ pub fn get(manager: Arc>, 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) } }; @@ -305,7 +305,7 @@ fn handle_ipc_message(message: String, manager: &AppManager, 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() )