-
Notifications
You must be signed in to change notification settings - Fork 227
Open
Description
This code compiles without issue, where generatedEvents
is of type [EKEvent]
and eventStore
is an EKEventStore
:
for thisEvent in generatedEvents {
let result = Result(try eventStore.save(thisEvent, span: .thisEvent, commit: false))
print(result)
}
However, when I rewrite it as a map (to generate an array of Result
s):
let results = generatedEvents.map { thisEvent -> Result<(), AnyError> in
let result = Result(try eventStore.save(thisEvent, span: .thisEvent, commit: false))
print(result)
return result
}
I receive the compiler error:
Call can throw, but it is not marked with 'try' and the error is not handled
However, looking at the Result
initializer, it looks like the error is handled in a do
/catch
block.
Metadata
Metadata
Assignees
Labels
No labels