Throws from notifications is very hard to debug -- XCode 8 doesn't show exact place where exception was raised, you see only EXC_BAD_ACCESS.
Example throw:
func backgroundContextDidSave(notification: NSNotification) throws {
if NSThread.isMainThread() && TestCheck.isTesting == false {
throw NSError(info: "Background context saved in the main thread. Use context's `performBlock`", previousError: nil)
My main goal is to give an ability to developer to catch a bug with correct error message and full method call history (throw won't give call stack correctly).
I don't know if throw from notification will crash binary on release build, on debug build it crashes.
My proposals:
Change notifications' throws to asserts, so you can see error message, exact place and correct view in debugger. Assert will be shown only on debug build, so in release mode application will try continue work without guarantees, may be Core Data won't raise an exception and all will be okay.
Change notifications' throws to fatalErrors, so application will terminate in any way in release & debug mode.
Throws from notifications is very hard to debug -- XCode 8 doesn't show exact place where exception was raised, you see only EXC_BAD_ACCESS.
Example throw:
My main goal is to give an ability to developer to catch a bug with correct error message and full method call history (throw won't give call stack correctly).
I don't know if throw from notification will crash binary on release build, on debug build it crashes.
My proposals:
throws
toasserts
, so you can see error message, exact place and correct view in debugger. Assert will be shown only on debug build, so in release mode application will try continue work without guarantees, may be Core Data won't raise an exception and all will be okay.throws
tofatalErrors
, so application will terminate in any way in release & debug mode.