mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-04-29 10:52:47 -04:00
feat: Enhance DaemonConnector and InspectorViewModel with Logging and Error Handling
- Integrated OS logging into DaemonConnector and InspectorViewModel for improved traceability of operations. - Added detailed logging for query execution and file loading processes, enhancing debugging capabilities. - Introduced custom error handling in InspectorViewModel to manage file loading errors more effectively. - Updated query methods to log success and failure cases, providing better insights into application behavior.
This commit is contained in:
@@ -751,11 +751,18 @@ extension SpacedriveClient {
|
||||
let response = try await sendRequest(.query(method: wireMethod, libraryId: getCurrentLibraryId(), payload: queryDict))
|
||||
|
||||
switch response {
|
||||
case .jsonOk(let anyCodable):
|
||||
// Convert AnyCodable to Data, then decode to File?
|
||||
let data = try JSONEncoder().encode(anyCodable)
|
||||
let result = try JSONDecoder().decode(File?.self, from: data)
|
||||
return result
|
||||
case .jsonOk(let jsonData):
|
||||
print("🔍 Decoding File from JSON data: \(jsonData.value)")
|
||||
do {
|
||||
let jsonResponseData = try JSONSerialization.data(withJSONObject: jsonData.value)
|
||||
let result = try JSONDecoder().decode(File.self, from: jsonResponseData)
|
||||
print("✅ Successfully decoded File: \(result.name)")
|
||||
return result
|
||||
} catch {
|
||||
print("❌ Failed to decode File: \(error)")
|
||||
print("❌ JSON data: \(jsonData.value)")
|
||||
throw SpacedriveError.invalidResponse("Failed to decode File: \(error)")
|
||||
}
|
||||
case .error(let error):
|
||||
throw SpacedriveError.daemonError("Query failed: \(error)")
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user