Skip to content

Commit 3461cbb

Browse files
authored
Make ObjectiveCError type Sendable without warnings (#73)
* Make ObjectiveCError type Sendable without warnings * Add comments to offsetInFile checking
1 parent 61f099f commit 3461cbb

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

Sources/CacheAdvance/CacheReader.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,13 @@ final class CacheReader {
5454
if offsetInFile == endOffset {
5555
break
5656
} else if offsetInFile > endOffset {
57+
// The messages on disk are out of sync with our header data.
5758
throw CacheAdvanceError.fileCorrupted
5859
}
5960
}
6061
}
6162
if let endOffset = endOffset, offsetInFile != endOffset {
63+
// 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.
6264
throw CacheAdvanceError.fileCorrupted
6365
}
6466
return encodedMessages

Sources/CacheAdvance/ObjectiveC.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ final class ObjectiveC {
3434
SwiftTryCatch.try({
3535
result = .success(work())
3636
}, catch: { exception in
37-
result = .failure(ObjectiveCError(exception: exception))
37+
result = .failure(ObjectiveCError(
38+
exceptionName: exception.name,
39+
reason: exception.reason))
3840
})
3941

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

5254
/// A `throw`able NSException.
5355
struct ObjectiveCError: Error {
54-
let exception: NSException
56+
let exceptionName: NSExceptionName
57+
let reason: String?
5558
}

0 commit comments

Comments
 (0)