pointfreeco / swift-custom-dump

A collection of tools for debugging, diffing, and testing your application's data structures.
MIT License
800 stars 89 forks source link

Improve dumping of Errors bridged to NSError #17

Closed aroben closed 3 years ago

aroben commented 3 years ago

When dumping a Swift Error bridged to NSError, we'd only show the error domain and error code generated by the Swift runtime. We can get much better output (e.g., enum/case names, associated values, etc.) if we unwrap the Swift Error and dump it directly.

aroben commented 3 years ago

Looks like CI is failing on Ubuntu due to https://bugs.swift.org/browse/SR-15191.

We could make this enhancement macOS-only, or we could just leave it out. Let me know if you have any other ideas @stephencelis.

stephencelis commented 3 years ago

And _getEmbeddedNSError didn't have the problem? I guess _getEmbeddedNSError is technically public, so I'd be OK bringing it back if it avoids the issue. My initial reaction was to avoid it but may not be worth it!

aroben commented 3 years ago

Unfortunately, no. That method doesn't exist on Linux; I hadn't tested Linux at all before opening this PR.

aroben commented 3 years ago

I think your instinct to avoid it was a good one. Some Swift folks have told me that a type-based check is the intended way to do this, and the Linux behavior is a bug. I don't yet have any ideas for how to work around it on Linux though.

aroben commented 3 years ago

@stephencelis I updated the test to reflect the current behavior on Linux. It's unfortunate the behavior isn't the same as macOS, but I don't think there's much we can do about that within swift-custom-dump.

stephencelis commented 3 years ago

Sounds good! I'll merge when tests pass :smile: Thanks for the PR!