mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-07-14 19:10:28 +03:00
fix(core): Set json content type for errors returned from commands (#9213)
This commit is contained in:
parent
75f5cb4015
commit
81b853bc87
5
.changes/fix-ipc-error-json.md
Normal file
5
.changes/fix-ipc-error-json.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
tauri: 'patch:bug'
|
||||
---
|
||||
|
||||
Fixed an issue where errors where returned as strings instead of objects from commands.
|
@ -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)
|
||||
}
|
||||
};
|
||||
|
||||
@ -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()
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user