[swift-users] intercept fatalError() or other termination messages from swift?

David Baraff davidbaraff at gmail.com
Fri Jun 23 23:42:09 CDT 2017


Is it possible that Apple’s own xcode tools just don’t show you the string, but it’s there anyway?  that seems pretty bogus…

> On Jun 23, 2017, at 9:40 PM, Jon Shier via swift-users <swift-users at swift.org> wrote:
> 
> Crashlytics can pick up these strings just fine. I thought they were part of the full crash dump. 
> 
>> On Jun 24, 2017, at 12:13 AM, David Baraff via swift-users <swift-users at swift.org> wrote:
>> 
>> I realize this is slightly centric to iOS, but it irks me that both Apple’s crash report logs and popular platforms like PLCrashReporter can do the hard stuff like give you a stack trace, but are *completely* unable to display the error message from terminating a program via fatalError(), or the error message from, e.g. dying with a bad optional.
>> 
>> Is there *any* to intercept the error messages that from fatalError() and similar like things in swift (bad optionals, invalid array accesses, assertions)?  I would think that some sort of a “hook” into these standard error routines would be a good thing.
>> 
>> In my case, if I could simply save that darn error string in a file, i could pick it up when the app next launches and report it along with the rest of the info like the stack/signal, etc.
>> 
>> I’ve been looking through the code in stdlib/public/runtime/Errors.cpp but haven’t found anything promising that lets me jump in there.  In my code, I’m likely to write things like
>>   guard let x = … else {
>>       fatalError(“Data type has payload <T> but is hooked to UI control with intrinsic type <U>”)
>>   }
>> 
>> and having that exact string tells me precisely what’s going, far simpler than a stack trace.
>> 
>> 
>> _______________________________________________
>> swift-users mailing list
>> swift-users at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-users
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users



More information about the swift-users mailing list