You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ask Foundation to capture NSError/CFError backtraces for us. (#673)
On Apple platforms, when an error occurs in an Objective-C method or C
function, convention is to return the error as an instance of
`NSError`/`CFError` via an out-parameter. When that Objective-C method
or C function is called by a Swift function, the Swift function detects
the error, then effectively rethrows it, at which point our
`swift_willThrow` hook is triggered. This can obscure the real origin of
the error which may be many stack frames down from the point Swift takes
over.
This PR asks Foundation, via a relatively new internal function, to
capture backtraces for instances of `NSError` and `CFError` at the point
they are created. Then, when Swift Testing attempts to look up the
backtrace for an error it has caught, if Foundation has generated one,
then Swift Testing can substitute it in place of the one it generated in
the `swift_willThrow` hook.
Resolves rdar://114386243.
### Checklist:
- [x] Code and documentation should follow the style of the [Style
Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md).
- [x] If public symbols are renamed or modified, DocC references should
be updated.
0 commit comments