Skip to content

Commit

Permalink
Make ObjectiveCError type Sendable without warnings (#73)
Browse files Browse the repository at this point in the history
* Make ObjectiveCError type Sendable without warnings

* Add comments to offsetInFile checking
  • Loading branch information
dfed committed Nov 19, 2022
1 parent 61f099f commit 3461cbb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Sources/CacheAdvance/CacheReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ final class CacheReader {
if offsetInFile == endOffset {
break
} else if offsetInFile > endOffset {
// The messages on disk are out of sync with our header data.
throw CacheAdvanceError.fileCorrupted
}
}
}
if let endOffset = endOffset, offsetInFile != endOffset {
// If we finished reading messages but our offset in the file is less (or greater) than our expected ending offset, our header data is incorrect.
throw CacheAdvanceError.fileCorrupted
}
return encodedMessages
Expand Down
7 changes: 5 additions & 2 deletions Sources/CacheAdvance/ObjectiveC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ final class ObjectiveC {
SwiftTryCatch.try({
result = .success(work())
}, catch: { exception in
result = .failure(ObjectiveCError(exception: exception))
result = .failure(ObjectiveCError(
exceptionName: exception.name,
reason: exception.reason))
})

switch result {
Expand All @@ -51,5 +53,6 @@ struct ObjectiveCTryFailure: Error {}

/// A `throw`able NSException.
struct ObjectiveCError: Error {
let exception: NSException
let exceptionName: NSExceptionName
let reason: String?
}

0 comments on commit 3461cbb

Please sign in to comment.