Merge branch 'charlesmchen/owsFailSwift'

pull/1/head
Matthew Chen 7 years ago
commit fa09ce08f2

@ -35,6 +35,7 @@
3471B1DA1EB7C63600F6AEC8 /* NewNonContactConversationViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3471B1D91EB7C63600F6AEC8 /* NewNonContactConversationViewController.m */; };
3472229F1EB22FFE00E53955 /* AddToGroupViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3472229E1EB22FFE00E53955 /* AddToGroupViewController.m */; };
348F2EAE1F0D21BC00D4ECE0 /* DeviceSleepManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 348F2EAD1F0D21BC00D4ECE0 /* DeviceSleepManager.swift */; };
3495BC901F1400FF00B478F5 /* OWSAsserts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3495BC8F1F1400FF00B478F5 /* OWSAsserts.swift */; };
3497DBEC1ECE257500DB2605 /* OWSCountryMetadata.m in Sources */ = {isa = PBXBuildFile; fileRef = 3497DBEB1ECE257500DB2605 /* OWSCountryMetadata.m */; };
3497DBEF1ECE2E4700DB2605 /* DomainFrontingCountryViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3497DBEE1ECE2E4700DB2605 /* DomainFrontingCountryViewController.m */; };
34B3F8711E8DF1700035BE1A /* AboutTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34B3F8351E8DF1700035BE1A /* AboutTableViewController.m */; };
@ -416,6 +417,7 @@
3472229D1EB22FFE00E53955 /* AddToGroupViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AddToGroupViewController.h; sourceTree = "<group>"; };
3472229E1EB22FFE00E53955 /* AddToGroupViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AddToGroupViewController.m; sourceTree = "<group>"; };
348F2EAD1F0D21BC00D4ECE0 /* DeviceSleepManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DeviceSleepManager.swift; sourceTree = "<group>"; };
3495BC8F1F1400FF00B478F5 /* OWSAsserts.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OWSAsserts.swift; sourceTree = "<group>"; };
3497DBEA1ECE257500DB2605 /* OWSCountryMetadata.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSCountryMetadata.h; sourceTree = "<group>"; };
3497DBEB1ECE257500DB2605 /* OWSCountryMetadata.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSCountryMetadata.m; sourceTree = "<group>"; };
3497DBED1ECE2E4700DB2605 /* DomainFrontingCountryViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DomainFrontingCountryViewController.h; sourceTree = "<group>"; };
@ -1340,6 +1342,7 @@
BFB074C619A5611000F2947C /* ObservableValue.m */,
76EB04EE18170B33006006FC /* Operation.h */,
76EB04EF18170B33006006FC /* Operation.m */,
3495BC8F1F1400FF00B478F5 /* OWSAsserts.swift */,
34D5CC941EA6AFAD005515DB /* OWSContactsSyncing.h */,
34D5CC951EA6AFAD005515DB /* OWSContactsSyncing.m */,
45CD81F01DC03A22004C9430 /* OWSLogger.h */,
@ -2154,6 +2157,7 @@
45666EC91D994C0D008FE134 /* OWSGroupAvatarBuilder.m in Sources */,
3471B1DA1EB7C63600F6AEC8 /* NewNonContactConversationViewController.m in Sources */,
34B3F87C1E8DF1700035BE1A /* FingerprintViewController.m in Sources */,
3495BC901F1400FF00B478F5 /* OWSAsserts.swift in Sources */,
76EB058218170B33006006FC /* Environment.m in Sources */,
34B3F8921E8DF1710035BE1A /* SignalAttachment.swift in Sources */,
45464DBC1DFA041F001D3FD6 /* DataChannelMessage.swift in Sources */,

@ -23,7 +23,7 @@ class AttachmentPointerAdapter: JSQMediaItem, OWSMessageEditing {
@available(*, unavailable)
required init?(coder aDecoder: NSCoder) {
assertionFailure("init(coder:) has not been implemented")
owsFail("init(coder:) has not been implemented")
self.isIncoming = true
self.attachmentPointer = TSAttachmentPointer()
super.init(coder: aDecoder)
@ -36,8 +36,7 @@ class AttachmentPointerAdapter: JSQMediaItem, OWSMessageEditing {
func performAction(_ action: Selector) {
// Should not get here, as you can't perform any actions on a downloading attachment.
Logger.error("\(TAG) unexpectedly trying to perform action: \(action) on downloading attachment.")
assertionFailure()
owsFail("\(TAG) unexpectedly trying to perform action: \(action) on downloading attachment.")
}
// MARK: JSQ Overrides
@ -88,30 +87,26 @@ class AttachmentPointerAdapter: JSQMediaItem, OWSMessageEditing {
func attachmentDownloadProgress(_ notification: NSNotification) {
guard let attachmentPointerView = self.attachmentPointerView else {
Logger.error("\(TAG) downloading view was unexpectedly nil for notification: \(notification)")
assertionFailure()
owsFail("\(TAG) downloading view was unexpectedly nil for notification: \(notification)")
return
}
guard let userInfo = notification.userInfo else {
Logger.error("\(TAG) user info was unexpectedly nil for notification: \(notification)")
assertionFailure()
owsFail("\(TAG) user info was unexpectedly nil for notification: \(notification)")
return
}
guard let progress = userInfo[kAttachmentDownloadProgressKey] as? CGFloat else {
Logger.error("\(TAG) missing progress measure for notification user info: \(userInfo)")
assertionFailure()
owsFail("\(TAG) missing progress measure for notification user info: \(userInfo)")
return
}
guard let attachmentId = userInfo[kAttachmentDownloadAttachmentIDKey] as? String else {
Logger.error("\(TAG) missing attachmentId for notification user info: \(userInfo)")
assertionFailure()
owsFail("\(TAG) missing attachmentId for notification user info: \(userInfo)")
return
}
if (self.attachmentPointer.uniqueId == attachmentId) {
if self.attachmentPointer.uniqueId == attachmentId {
attachmentPointerView.progress = progress
}
}

@ -62,8 +62,7 @@ class ProfileFetcherJob: NSObject {
request,
success: { (_: URLSessionDataTask?, responseObject: Any?) -> Void in
guard let profileResponse = SignalServiceProfile(recipientId: recipientId, rawResponse: responseObject) else {
Logger.error("\(self.TAG) response object had unexpected content")
assertionFailure("\(self.TAG) response object had unexpected content")
owsFail("\(self.TAG) response object had unexpected content")
return
}
@ -71,8 +70,7 @@ class ProfileFetcherJob: NSObject {
},
failure: { (_: URLSessionDataTask?, error: Error?) in
guard let error = error else {
Logger.error("\(self.TAG) error in \(#function) was surpringly nil. sheesh rough day.")
assertionFailure("\(self.TAG) error in \(#function) was surpringly nil. sheesh rough day.")
owsFail("\(self.TAG) error in \(#function) was surpringly nil. sheesh rough day.")
return
}

@ -33,7 +33,7 @@ class AttachmentApprovalViewController: UIViewController, OWSAudioAttachmentPlay
dataUTI: kUTTypeContent as String,
filename:nil)
super.init(coder: aDecoder)
assertionFailure()
owsFail("\(self.TAG) invalid constructor")
}
required init(attachment: SignalAttachment, successCompletion : @escaping () -> Void) {
@ -438,7 +438,7 @@ class AttachmentApprovalViewController: UIViewController, OWSAudioAttachmentPlay
private func updateAudioStatusLabel() {
guard let audioStatusLabel = self.audioStatusLabel else {
assertionFailure("Missing audio status label")
owsFail("Missing audio status label")
return
}

@ -165,8 +165,7 @@ class ExperienceUpgradesPageViewController: UIViewController, UIPageViewControll
override func viewDidLoad() {
guard let firstViewController = allViewControllers.first else {
Logger.error("\(TAG) no pages to show.")
assertionFailure()
owsFail("\(TAG) no pages to show.")
dismiss(animated: true)
return
}
@ -246,8 +245,7 @@ class ExperienceUpgradesPageViewController: UIViewController, UIPageViewControll
public func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
Logger.debug("\(TAG) in \(#function)")
guard let currentIndex = self.viewControllerIndexes[viewController] else {
assertionFailure()
Logger.error("\(TAG) unknown view controller: \(viewController)")
owsFail("\(TAG) unknown view controller: \(viewController)")
return nil
}
@ -262,8 +260,7 @@ class ExperienceUpgradesPageViewController: UIViewController, UIPageViewControll
public func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {
Logger.debug("\(TAG) in \(#function)")
guard let currentIndex = self.viewControllerIndexes[viewController] else {
assertionFailure()
Logger.error("\(TAG) unknown view controller: \(viewController)")
owsFail("\(TAG) unknown view controller: \(viewController)")
return nil
}
@ -296,8 +293,7 @@ class ExperienceUpgradesPageViewController: UIViewController, UIPageViewControll
public func addViewController(experienceUpgrade: ExperienceUpgrade) {
guard let identifier = ExperienceUpgradeId(rawValue: experienceUpgrade.uniqueId) else {
Logger.error("\(TAG) unknown experience upgrade. skipping")
assertionFailure()
owsFail("\(TAG) unknown experience upgrade. skipping")
return
}

@ -130,8 +130,7 @@ class SignalAttachment: NSObject {
do {
try data.write(to: fileUrl)
} catch {
Logger.error("\(SignalAttachment.TAG) Could not write data to disk: \(dataUTI)")
assertionFailure()
owsFail("\(SignalAttachment.TAG) Could not write data to disk: \(dataUTI)")
return nil
}
temporaryDataUrl = fileUrl
@ -146,7 +145,7 @@ class SignalAttachment: NSObject {
var errorName: String? {
guard let error = error else {
// This method should only be called if there is an error.
assertionFailure()
owsFail("Missing error")
return nil
}
@ -156,7 +155,7 @@ class SignalAttachment: NSObject {
var localizedErrorDescription: String? {
guard let error = self.error else {
// This method should only be called if there is an error.
assertionFailure()
owsFail("Missing error")
return nil
}
@ -366,8 +365,7 @@ class SignalAttachment: NSObject {
for dataUTI in inputImageUTISet {
if pasteboardUTISet.contains(dataUTI) {
guard let data = dataForFirstPasteboardItem(dataUTI:dataUTI) else {
Logger.error("\(TAG) Missing expected pasteboard data for UTI: \(dataUTI)")
assertionFailure()
owsFail("\(TAG) Missing expected pasteboard data for UTI: \(dataUTI)")
return nil
}
return imageAttachment(data : data, dataUTI : dataUTI, filename: nil)
@ -376,8 +374,7 @@ class SignalAttachment: NSObject {
for dataUTI in videoUTISet {
if pasteboardUTISet.contains(dataUTI) {
guard let data = dataForFirstPasteboardItem(dataUTI:dataUTI) else {
Logger.error("\(TAG) Missing expected pasteboard data for UTI: \(dataUTI)")
assertionFailure()
owsFail("\(TAG) Missing expected pasteboard data for UTI: \(dataUTI)")
return nil
}
return videoAttachment(data : data, dataUTI : dataUTI, filename: nil)
@ -386,8 +383,7 @@ class SignalAttachment: NSObject {
for dataUTI in audioUTISet {
if pasteboardUTISet.contains(dataUTI) {
guard let data = dataForFirstPasteboardItem(dataUTI:dataUTI) else {
Logger.error("\(TAG) Missing expected pasteboard data for UTI: \(dataUTI)")
assertionFailure()
owsFail("\(TAG) Missing expected pasteboard data for UTI: \(dataUTI)")
return nil
}
return audioAttachment(data : data, dataUTI : dataUTI, filename: nil)
@ -396,8 +392,7 @@ class SignalAttachment: NSObject {
let dataUTI = pasteboardUTISet[pasteboardUTISet.startIndex]
guard let data = dataForFirstPasteboardItem(dataUTI:dataUTI) else {
Logger.error("\(TAG) Missing expected pasteboard data for UTI: \(dataUTI)")
assertionFailure()
owsFail("\(TAG) Missing expected pasteboard data for UTI: \(dataUTI)")
return nil
}
return genericAttachment(data : data, dataUTI : dataUTI, filename: nil)
@ -408,18 +403,15 @@ class SignalAttachment: NSObject {
private class func dataForFirstPasteboardItem(dataUTI: String) -> Data? {
let itemSet = IndexSet(integer:0)
guard let datas = UIPasteboard.general.data(forPasteboardType:dataUTI, inItemSet:itemSet) else {
Logger.error("\(TAG) Missing expected pasteboard data for UTI: \(dataUTI)")
assertionFailure()
owsFail("\(TAG) Missing expected pasteboard data for UTI: \(dataUTI)")
return nil
}
guard datas.count > 0 else {
Logger.error("\(TAG) Missing expected pasteboard data for UTI: \(dataUTI)")
assertionFailure()
owsFail("\(TAG) Missing expected pasteboard data for UTI: \(dataUTI)")
return nil
}
guard let data = datas[0] as? Data else {
Logger.error("\(TAG) Missing expected pasteboard data for UTI: \(dataUTI)")
assertionFailure()
owsFail("\(TAG) Missing expected pasteboard data for UTI: \(dataUTI)")
return nil
}
return data

@ -42,9 +42,8 @@ import AVFoundation
newPlayer?.numberOfLoops = -1
}
} catch {
Logger.error("\(self.TAG) faild to build audio player with error: \(error)")
owsFail("\(self.TAG) failed to build audio player with error: \(error)")
newPlayer = nil
assertionFailure()
}
return newPlayer
}()
@ -254,8 +253,7 @@ import AVFoundation
private func play(sound: Sound) {
guard let newPlayer = sound.player else {
Logger.error("\(self.TAG) unable to build player")
assertionFailure()
owsFail("\(self.TAG) unable to build player")
return
}
Logger.info("\(self.TAG) playing sound: \(sound.filePath)")
@ -355,8 +353,7 @@ import AVFoundation
}
} catch {
let message = "\(self.TAG) in \(#function) failed to set category: \(category) mode: \(String(describing: mode)), options: \(options) with error: \(error)"
assertionFailure(message)
Logger.error(message)
owsFail(message)
}
}
}

@ -290,7 +290,7 @@ protocol CallServiceObserver: class {
throw CallError.obsoleteCall(description:"obsolete call in \(#function)")
}
guard let peerConnectionClient = self.peerConnectionClient else {
assertionFailure("Missing peerConnectionClient in \(#function)")
owsFail("Missing peerConnectionClient in \(#function)")
throw CallError.obsoleteCall(description:"Missing peerConnectionClient in \(#function)")
}
@ -449,8 +449,7 @@ protocol CallServiceObserver: class {
switch untrustedIdentity!.verificationState {
case .verified:
Logger.error("\(TAG) shouldn't have missed a call due to untrusted identity if the identity is verified")
assertionFailure("shouldn't have missed a call due to untrusted identity if the identity is verified")
owsFail("\(TAG) shouldn't have missed a call due to untrusted identity if the identity is verified")
self.notificationsAdapter.presentMissedCall(newCall, callerName: callerName)
case .default:
self.notificationsAdapter.presentMissedCallBecauseOfNewIdentity(call: newCall, callerName: callerName)
@ -733,14 +732,14 @@ protocol CallServiceObserver: class {
guard let call = self.call else {
// This should never happen; return to a known good state.
assertionFailure("\(TAG) call was unexpectedly nil in \(#function)")
owsFail("\(TAG) call was unexpectedly nil in \(#function)")
handleFailedCurrentCall(error: .assertionError(description:"\(TAG) call was unexpectedly nil in \(#function)"))
return
}
guard call.localId == localId else {
// This should never happen; return to a known good state.
assertionFailure("\(TAG) callLocalId:\(localId) doesn't match current calls: \(call.localId)")
owsFail("\(TAG) callLocalId:\(localId) doesn't match current calls: \(call.localId)")
handleFailedCurrentCall(error: .assertionError(description:"\(TAG) callLocalId:\(localId) doesn't match current calls: \(call.localId)"))
return
}
@ -823,14 +822,14 @@ protocol CallServiceObserver: class {
guard let call = self.call else {
// This should never happen; return to a known good state.
assertionFailure("\(TAG) call was unexpectedly nil in \(#function)")
owsFail("\(TAG) call was unexpectedly nil in \(#function)")
handleFailedCurrentCall(error: .assertionError(description:"\(TAG) call was unexpectedly nil in \(#function)"))
return
}
guard call.localId == localId else {
// This should never happen; return to a known good state.
assertionFailure("\(TAG) callLocalId:\(localId) doesn't match current calls: \(call.localId)")
owsFail("\(TAG) callLocalId:\(localId) doesn't match current calls: \(call.localId)")
handleFailedCurrentCall(error: .assertionError(description:"\(TAG) callLocalId:\(localId) doesn't match current calls: \(call.localId)"))
return
}
@ -849,7 +848,7 @@ protocol CallServiceObserver: class {
Logger.info("\(TAG) in \(#function): \(call.identifiersForLogs).")
if let callRecord = call.callRecord {
assertionFailure("Not expecting callrecord to already be set")
owsFail("Not expecting callrecord to already be set")
callRecord.updateCallType(RPRecentCallTypeIncomingDeclined)
} else {
let callRecord = TSCall(timestamp: NSDate.ows_millisecondTimeStamp(), withCallNumber: call.remotePhoneNumber, callType: RPRecentCallTypeIncomingDeclined, in: call.thread)
@ -919,7 +918,7 @@ protocol CallServiceObserver: class {
guard let call = self.call else {
// This should never happen; return to a known good state.
assertionFailure("\(TAG) call was unexpectedly nil in \(#function)")
owsFail("\(TAG) call was unexpectedly nil in \(#function)")
handleFailedCurrentCall(error: .assertionError(description:"\(TAG) call unexpectedly nil in \(#function)"))
return
}
@ -973,7 +972,7 @@ protocol CallServiceObserver: class {
guard let call = self.call else {
// This should never happen; return to a known good state.
assertionFailure("\(TAG) call was unexpectedly nil in \(#function)")
owsFail("\(TAG) call was unexpectedly nil in \(#function)")
handleFailedCurrentCall(error: .assertionError(description:"\(TAG) call unexpectedly nil in \(#function)"))
return
}
@ -1011,7 +1010,7 @@ protocol CallServiceObserver: class {
guard let call = self.call else {
// This should never happen; return to a known good state.
assertionFailure("\(TAG) received data message, but there is no current call. Ignoring.")
owsFail("\(TAG) received data message, but there is no current call. Ignoring.")
handleFailedCurrentCall(error: .assertionError(description:"\(TAG) received data message, but there is no current call. Ignoring."))
return
}
@ -1023,7 +1022,7 @@ protocol CallServiceObserver: class {
guard connected.id == call.signalingId else {
// This should never happen; return to a known good state.
assertionFailure("\(TAG) received connected message for call with id:\(connected.id) but current call has id:\(call.signalingId)")
owsFail("\(TAG) received connected message for call with id:\(connected.id) but current call has id:\(call.signalingId)")
handleFailedCurrentCall(error: .assertionError(description:"\(TAG) received connected message for call with id:\(connected.id) but current call has id:\(call.signalingId)"))
return
}
@ -1038,7 +1037,7 @@ protocol CallServiceObserver: class {
guard hangup.id == call.signalingId else {
// This should never happen; return to a known good state.
assertionFailure("\(TAG) received hangup message for call with id:\(hangup.id) but current call has id:\(call.signalingId)")
owsFail("\(TAG) received hangup message for call with id:\(hangup.id) but current call has id:\(call.signalingId)")
handleFailedCurrentCall(error: .assertionError(description:"\(TAG) received hangup message for call with id:\(hangup.id) but current call has id:\(call.signalingId)"))
return
}
@ -1231,7 +1230,7 @@ protocol CallServiceObserver: class {
AssertIsOnMainThread()
if case .assertionError(let description) = error {
assertionFailure(description)
owsFail(description)
}
if let failedCall = failedCall {

@ -61,12 +61,12 @@ class NonCallKitCallUIAdaptee: CallUIAdaptee {
AssertIsOnMainThread()
guard let call = self.callService.call else {
assertionFailure("\(self.TAG) in \(#function) No current call.")
owsFail("\(self.TAG) in \(#function) No current call.")
return
}
guard call.localId == localId else {
assertionFailure("\(self.TAG) in \(#function) localId does not match current call")
owsFail("\(self.TAG) in \(#function) localId does not match current call")
return
}
@ -77,7 +77,7 @@ class NonCallKitCallUIAdaptee: CallUIAdaptee {
AssertIsOnMainThread()
guard call.localId == self.callService.call?.localId else {
assertionFailure("\(self.TAG) in \(#function) localId does not match current call")
owsFail("\(self.TAG) in \(#function) localId does not match current call")
return
}
@ -89,12 +89,12 @@ class NonCallKitCallUIAdaptee: CallUIAdaptee {
AssertIsOnMainThread()
guard let call = self.callService.call else {
assertionFailure("\(self.TAG) in \(#function) No current call.")
owsFail("\(self.TAG) in \(#function) No current call.")
return
}
guard call.localId == localId else {
assertionFailure("\(self.TAG) in \(#function) localId does not match current call")
owsFail("\(self.TAG) in \(#function) localId does not match current call")
return
}
@ -105,7 +105,7 @@ class NonCallKitCallUIAdaptee: CallUIAdaptee {
AssertIsOnMainThread()
guard call.localId == self.callService.call?.localId else {
assertionFailure("\(self.TAG) in \(#function) localId does not match current call")
owsFail("\(self.TAG) in \(#function) localId does not match current call")
return
}
@ -124,7 +124,7 @@ class NonCallKitCallUIAdaptee: CallUIAdaptee {
// If both parties hang up at the same moment,
// call might already be nil.
guard self.callService.call == nil || call.localId == self.callService.call?.localId else {
assertionFailure("\(self.TAG) in \(#function) localId does not match current call")
owsFail("\(self.TAG) in \(#function) localId does not match current call")
return
}
@ -153,7 +153,7 @@ class NonCallKitCallUIAdaptee: CallUIAdaptee {
AssertIsOnMainThread()
guard call.localId == self.callService.call?.localId else {
assertionFailure("\(self.TAG) in \(#function) localId does not match current call")
owsFail("\(self.TAG) in \(#function) localId does not match current call")
return
}
@ -164,7 +164,7 @@ class NonCallKitCallUIAdaptee: CallUIAdaptee {
AssertIsOnMainThread()
guard call.localId == self.callService.call?.localId else {
assertionFailure("\(self.TAG) in \(#function) localId does not match current call")
owsFail("\(self.TAG) in \(#function) localId does not match current call")
return
}

@ -41,8 +41,7 @@ import Foundation
// Rather than an init-assigned dependency property, we access `callUIAdapter` via Environment
// because it can change after app launch due to user settings
guard let callUIAdapter = Environment.getCurrent().callUIAdapter else {
assertionFailure()
Logger.error("\(TAG) can't initiate call because callUIAdapter is nil")
owsFail("\(TAG) can't initiate call because callUIAdapter is nil")
return false
}

@ -227,8 +227,7 @@ class PeerConnectionClient: NSObject, RTCPeerConnectionDelegate, RTCDataChannelD
return
}
guard let videoCaptureSession = self.videoCaptureSession else {
Logger.error("\(self.TAG) videoCaptureSession was unexpectedly nil")
assertionFailure()
owsFail("\(self.TAG) videoCaptureSession was unexpectedly nil")
return
}

@ -132,7 +132,7 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
AssertIsOnMainThread()
Logger.debug("\(self.TAG) \(#function)")
assertionFailure("CallKit should answer calls via system call screen, not via notifications.")
owsFail("\(self.TAG) \(#function) CallKit should answer calls via system call screen, not via notifications.")
}
func answerCall(_ call: SignalCall) {
@ -144,9 +144,8 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
func declineCall(localId: UUID) {
AssertIsOnMainThread()
Logger.debug("\(self.TAG) \(#function)")
assertionFailure("CallKit should decline calls via system call screen, not via notifications.")
owsFail("\(self.TAG) \(#function) CallKit should decline calls via system call screen, not via notifications.")
}
func declineCall(_ call: SignalCall) {

@ -41,8 +41,7 @@ extension CallUIAdaptee {
callViewController.modalTransitionStyle = .crossDissolve
guard let presentingViewController = Environment.getCurrent().signalsViewController else {
Logger.error("in \(#function) view controller unexpectedly nil")
assertionFailure("in \(#function) view controller unexpectedly nil")
owsFail("in \(#function) view controller unexpectedly nil")
return
}

@ -76,8 +76,7 @@ class ContactsFrameworkContactStoreAdaptee: ContactStoreAdaptee {
@objc
func runChangeHandler() {
guard let changeHandler = self.changeHandler else {
Logger.error("\(TAG) trying to run change handler before it was registered")
assertionFailure()
owsFail("\(TAG) trying to run change handler before it was registered")
return
}
changeHandler()
@ -96,8 +95,7 @@ class ContactsFrameworkContactStoreAdaptee: ContactStoreAdaptee {
systemContacts.append(contact)
}
} catch let error as NSError {
Logger.error("\(self.TAG) Failed to fetch contacts with error:\(error)")
assertionFailure()
owsFail("\(self.TAG) Failed to fetch contacts with error:\(error)")
return .error(error)
}
@ -134,8 +132,7 @@ class AddressBookContactStoreAdaptee: ContactStoreAdaptee {
@objc
func runChangeHandler() {
guard let changeHandler = self.changeHandler else {
Logger.error("\(TAG) trying to run change handler before it was registered")
assertionFailure()
owsFail("\(TAG) trying to run change handler before it was registered")
return
}
changeHandler()
@ -180,7 +177,7 @@ class AddressBookContactStoreAdaptee: ContactStoreAdaptee {
let lastName = addressBookRecord.lastName
let phoneNumbers = addressBookRecord.phoneNumbers
if (firstName == nil && lastName == nil) {
if firstName == nil && lastName == nil {
if let companyName = addressBookRecord.companyName {
firstName = companyName
} else {
@ -338,8 +335,7 @@ class SystemContactsFetcher: NSObject {
public var isAuthorized: Bool {
guard self.authorizationStatus != .notDetermined else {
assertionFailure("should have called `requestOnce` before this point.")
Logger.error("\(TAG) should have called `requestOnce` before checking authorization status.")
owsFail("should have called `requestOnce` before checking authorization status.")
return false
}
@ -399,9 +395,8 @@ class SystemContactsFetcher: NSObject {
}
guard granted else {
Logger.info("\(self.TAG) declined contact access.")
// This case should have been caught be the error guard a few lines up.
assertionFailure()
owsFail("\(self.TAG) declined contact access.")
DispatchQueue.main.async {
completion?(nil)
}
@ -450,8 +445,7 @@ class SystemContactsFetcher: NSObject {
}
guard let contacts = fetchedContacts else {
Logger.error("\(self.TAG) contacts was unexpectedly not set.")
assertionFailure()
owsFail("\(self.TAG) contacts was unexpectedly not set.")
completion?(nil)
}

@ -26,7 +26,7 @@ class ExperienceUpgrade: TSYapDatabaseObject {
self.image = nil
super.init(uniqueId: uniqueId)
}
required init!(coder: NSCoder!) {
// This is the unfortunate seam between strict swift and fast-and-loose objc
// we can't leave these properties nil, since we really "don't know" that the superclass
@ -36,7 +36,7 @@ class ExperienceUpgrade: TSYapDatabaseObject {
self.image = nil
super.init(coder: coder)
}
required init(dictionary dictionaryValue: [AnyHashable : Any]!) throws {
// This is the unfortunate seam between strict swift and fast-and-loose objc
// we can't leave these properties nil, since we really "don't know" that the superclass
@ -57,7 +57,7 @@ class ExperienceUpgrade: TSYapDatabaseObject {
return super.storageBehaviorForProperty(withKey: propertyKey)
} else {
// Being conservative here in case we rename a property.
assertionFailure("unknown property \(propertyKey)")
owsFail("unknown property \(propertyKey)")
return super.storageBehaviorForProperty(withKey: propertyKey)
}
}

@ -0,0 +1,9 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
func owsFail(_ message: String) {
Logger.error(message)
Logger.flush()
assertionFailure(message)
}

@ -41,7 +41,7 @@ class AttachmentPointerView: UIView {
@available(*, unavailable)
override init(frame: CGRect) {
assertionFailure()
owsFail("invalid constructor")
// This initializer should never be called, but we assign some bogus values to keep the compiler happy.
self.filename = genericFilename
self.isIncoming = false
@ -53,7 +53,8 @@ class AttachmentPointerView: UIView {
@available(*, unavailable)
required init?(coder aDecoder: NSCoder) {
assertionFailure()
owsFail("Invalid constructor")
// This initializer should never be called, but we assign some bogus values to keep the compiler happy.
self.filename = genericFilename
self.isIncoming = false

@ -52,7 +52,7 @@ import UIKit
super.init(coder: aDecoder)
assertionFailure()
owsFail("\(self.tag) Invalid constructor")
}
public required init() {

Loading…
Cancel
Save