Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement Request: support for Swift error handling inside trap block #11

Open
uriah-eisenstein opened this issue Jun 30, 2019 · 0 comments

Comments

@uriah-eisenstein
Copy link

Using Swift 5 on Xcode 10.2: a Swift function which throws, when called inside a trap block, needs be wrapped in its own do { … try … } catch. This is because trap takes a non-throwing block as an argument.

I encountered this, for instance, with NSManagedObjectContext.save – it is a throwing function in Swift, but may also throw an Objective-C exception in case of invalid data or constraint violation.

(I tried making trap accept a throwing function myself, but it turned out not to be trivial, since Swift doesn't automatically translate an Objective-C block parameter taking NSError** into a Swift throwing function. The following link might be useful, I haven't had time to experiment further: https://stackoverflow.com/questions/49324917/swift-try-inside-objective-c-block)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant