Conversation
…uence.partitioned() and unit test for it
…ssionsInserter.insertSessions async
…tionalExistingSession() return nil on error, not throw
…sionFetchable.isExisting()
…sionsUpdatable.updateSessions() and update existing sessions
| Log.error("Error when saving changes in \(uuid) session: \(error.localizedDescription)") | ||
| return nil | ||
| } | ||
| } |
There was a problem hiding this comment.
I've checked the call chain of the method and in the end the only error handling was this line of logging, so I moved it here and made the method not throw, to handle the nil cases conveniently from the client code
There was a problem hiding this comment.
Behold, useless error throwing. Good call 👍
| extension Future where Failure == Error { | ||
| convenience init(asyncOperation: @escaping () async throws -> Output) { | ||
| self.init { promise in | ||
| Task { | ||
| do { | ||
| let result = try await asyncOperation() | ||
| promise(.success(result)) | ||
| } catch { | ||
| promise(.failure(error)) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Using this to bridge Future client code and refactored async code to get rid of the callbacks
| extension Sequence { | ||
| func partitioned(by condition: (Element) -> Bool) -> (matching: [Element], nonMatching: [Element]) { | ||
| var matching = [Element]() | ||
| var nonMatching = [Element]() | ||
|
|
||
| for element in self { | ||
| if condition(element) { | ||
| matching.append(element) | ||
| } else { | ||
| nonMatching.append(element) | ||
| } | ||
| } | ||
|
|
||
| return (matching, nonMatching) | ||
| } | ||
| } |
There was a problem hiding this comment.
Searched for some library that has this specifically but didn't find any
mpanuszewska
left a comment
There was a problem hiding this comment.
I didn't go through the business logic fully, trusting you on that, but from technical side everything looks good. Good to see you getting super comfortable with swift 😏
Really good job 👏
| Log.error("Error when saving changes in \(uuid) session: \(error.localizedDescription)") | ||
| return nil | ||
| } | ||
| } |
There was a problem hiding this comment.
Behold, useless error throwing. Good call 👍
| @@ -0,0 +1,18 @@ | |||
| struct BatchError: Error { | |||
There was a problem hiding this comment.
Cool, there is 99% chance it will not be used ever again ^^'
Contains fix for the ticket