Print stack trace for fatalError


(Harlan Haskins) #1

This is a simple proposal:

I think fatalError should dump a stack trace the same way NSExceptions do. In Xcode and lldb, we have the ability to view the stack trace at a given execution location. However, it's so much simpler to just print a stack trace when running outside of a debugger (at least when compiled in debug mode) that it'd help us tremendously when trying to fix bugs in Swift projects developed outside of Xcode.

For example, I'm working with a library and I have no idea what line in anything caused an optional unwrap. All I see is:

fatalError: unexpectedly found nil when unwrapping optional value

Thoughts?

- Harlan