We have a special logging function that represents a particular type of crash, and as such, internally it calls fatalError
. However, unlike fatalError
, when we use it in a guard
statement, it still complains we haven't exited the scope of the guard
.
I checked the source code and fatalError
returns -> Never
so I tried that, but that didn't work either. I also didn't see any attributes applied to it that may be telling the compiler 'this is the end of the road'.
So is it possible to have your own fatalError
-like method?
func myFatalError(memberName:String = #function) -> Never {
let message = "Failed in \(memberName)"
NSLog(message)
fatalError(message)
}