apple / apple/swift-log

Remove `throw error as! Failure` TaskLocal adopts typed throws

Open Beginner friendly
#481 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
4k
Forks
344
Avg merge
1d 15h
Merged PRs (30d)
4

Description

Swift issue https://github.com/swiftlang/swift/issues/75520

The code in question:

```
public func withLogger(
_ logger: Logger,
_ operation: (Logger) throws(Failure) -> Result
) throws(Failure) -> Result {
do {
return try Logger.withTaskLocalLogger(logger) {
try operation(logger)
}
} catch {
throw error as! Failure
}
}
```

Contributor guide

Open the contributing guide

Research direction

Start with the withLogger implementation shown in the issue and read Swift issue 75520 for the TaskLocal typed-throws behavior. Run the project's existing tests after removing the unnecessary forced cast; done means the code compiles and the operation preserves its declared Failure type.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
observability-sre
Issue type
Refactor
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.