Safer concurrency
Warnings for unhandled task errors
Swift 6.4 warns when an error thrown inside an unstructured Task could be silently ignored, helping you catch potential bugs before they ship.
Before Swift 6.4
In Swift 6.3 and earlier, this task could throw an error without producing a warning when its result was discarded:
func doSomething() {
Task {
try await myAsyncThrowableMethod()
}
}
Swift 6.4
The compiler now warns about the potentially unhandled error:
func doSomething() {
Task { // Warning: task may produce an unhandled error
try await myAsyncThrowableMethod()
}
}
Handle the error inside the task with do and catch, or keep and consume the task’s result when appropriate.