From ecc4791342184c4b62716e7096d796d0b2c0ba36 Mon Sep 17 00:00:00 2001 From: Laurent Date: Fri, 6 Sep 2024 12:55:20 +0200 Subject: [PATCH] Fix crash --- LeStorage/StoreCenter.swift | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/LeStorage/StoreCenter.swift b/LeStorage/StoreCenter.swift index b7d52d6..3eca267 100644 --- a/LeStorage/StoreCenter.swift +++ b/LeStorage/StoreCenter.swift @@ -300,7 +300,14 @@ public class StoreCenter { let authValue = request.allHTTPHeaderFields?["Authorization"] let string = try apiCall.jsonString() let failedAPICall = FailedAPICall(callId: apiCall.id, type: collectionName, apiCall: string, error: error, authentication: authValue) - try failedAPICallsCollection.addOrUpdate(instance: failedAPICall) + + DispatchQueue.main.async { + do { + try failedAPICallsCollection.addOrUpdate(instance: failedAPICall) + } catch { + Logger.error(error) + } + } } catch { Logger.error(error) } @@ -308,7 +315,6 @@ public class StoreCenter { } } - } /// Logs a failed Api call with its request and error message