How can I capture / log a fatal error in Swift? -


for example, fatal error: unexpectedly found nil while unwrapping optional value. regardless of cause, can data captured? stderr or else?

edit: found reference @ http://swiftdoc.org/func/fatalerror/ says function (which i'm assuming indeed swift internally calling) "unconditionally print message , stop execution.". perhaps there's nothing left ahold of remote crash report via testflight crash reports or having device handy.

i'm able log uncaught exceptions via nssetuncaughtexceptionhandler in main.swift, , have logging going on in other parts of our app wherever bad (but possible) errors can occur. hoping log these fatal errors our logs show more complete picture of crashes occuring on remote testing devices.

certain errors go stderr. here simple example:

$ cat tryit  #! /usr/bin/env swift  println ("foo") precondition (false, "bar") $ ./tryit 2> /tmp/error 1> /tmp/noterror illegal instruction: 4 $ cat /tmp/noterror  $ cat /tmp/error precondition failed: bar: file ./tryit, line 4 0  swift                    0x000000010f7faa18 llvm::sys::printstacktrace(__sfile*) + 40 1  swift                    0x000000010f7faef4 signalhandler(int) + 452 ... 

if remove precondition, results go stdout:

$ cat tryit  #! /usr/bin/env swift  println ("foo") $ ./tryit 2> /tmp/error 1> /tmp/noterror $ cat /tmp/noterror  foo $ cat /tmp/error  

Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -