File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed
Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -196,7 +196,7 @@ class ApiManager {
196196 }
197197
198198 default :
199- completion ( . failure( APIError . custom ( " Unexpected HTTP status code: \( response. statusCode) " ) ) )
199+ completion ( . failure( APIError ( statusCode : response. statusCode) ) )
200200 }
201201 } else {
202202 completion ( . failure( APIError . custom ( " No valid HTTP response received " ) ) )
Original file line number Diff line number Diff line change @@ -18,27 +18,27 @@ class DatasyncManager {
1818 private var isSynching : Bool = false
1919
2020 private let dbInstance = DatabaseConnector . shared
21-
22- func syncDataToOSM( completionHandler: @escaping ( Bool ) -> Void ) {
21+
22+ func syncDataToOSM( completionHandler: @escaping ( Result < Bool , APIError > ) -> Void ) {
2323 Task {
2424 do {
2525 let isSynced = try await syncData ( )
2626 print ( " Sync finished " )
2727 if isSynced {
2828 print ( " Sync successful " )
2929 DispatchQueue . main. async {
30- completionHandler ( true ) // Success
30+ completionHandler ( . success ( true ) ) // Success
3131 }
3232 } else {
3333 print ( " Sync failed " )
3434 DispatchQueue . main. async {
35- completionHandler ( false ) // Failure
35+ completionHandler ( . failure ( APIError . custom ( " Sync failed. Please try again. " ) ) ) // Failure
3636 }
3737 }
3838 } catch {
3939 print ( " Sync failed: \( error) " )
4040 DispatchQueue . main. async {
41- completionHandler ( false ) // Failure
41+ completionHandler ( . failure ( error as! APIError ) ) // Failure
4242 }
4343 }
4444 }
You can’t perform that action at this time.
0 commit comments