Rename fail macros in Swift.

This commit is contained in:
Matthew Chen 2018-08-27 10:27:48 -04:00
parent 7be8f30877
commit 5b50e81b4f
72 changed files with 430 additions and 429 deletions

View File

@ -67,7 +67,7 @@ class ConversationConfigurationSyncOperation: OWSOperation {
var dataSource: DataSource?
self.dbConnection.readWrite { transaction in
guard let messageData: Data = syncMessage.buildPlainTextAttachmentData(with: transaction) else {
owsFail("could not serialize sync contacts data")
owsFailDebug("could not serialize sync contacts data")
return
}
dataSource = DataSourceValue.dataSource(withSyncMessageData: messageData)
@ -91,7 +91,7 @@ class ConversationConfigurationSyncOperation: OWSOperation {
var dataSource: DataSource?
self.dbConnection.read { transaction in
guard let messageData: Data = syncMessage.buildPlainTextAttachmentData(with: transaction) else {
owsFail("could not serialize sync groups data")
owsFailDebug("could not serialize sync groups data")
return
}
dataSource = DataSourceValue.dataSource(withSyncMessageData: messageData)

View File

@ -45,7 +45,7 @@ public class MessageFetcherJob: NSObject {
let envelopeData = try envelope.serializedData()
self.messageReceiver.handleReceivedEnvelopeData(envelopeData)
} catch {
owsFail("failed to serialize envelope")
owsFailDebug("failed to serialize envelope")
}
self.acknowledgeDelivery(envelope: envelope)
}
@ -154,7 +154,7 @@ public class MessageFetcherJob: NSObject {
return try builder.build()
} catch {
owsFail("error building envelope: \(error)")
owsFailDebug("error building envelope: \(error)")
return nil
}
}

View File

@ -36,7 +36,7 @@ import SignalMessaging
func run(retryDelay: TimeInterval = 1) {
guard let localNumber = TSAccountManager.localNumber() else {
owsFail("localNumber was unexpectedly nil")
owsFailDebug("localNumber was unexpectedly nil")
return
}
@ -49,14 +49,14 @@ import SignalMessaging
var dataSource: DataSource?
self.editingDatabaseConnection.readWrite { transaction in
guard let messageData: Data = syncContactsMessage.buildPlainTextAttachmentData(with: transaction) else {
owsFail("could not serialize sync contacts data")
owsFailDebug("could not serialize sync contacts data")
return
}
dataSource = DataSourceValue.dataSource(withSyncMessageData: messageData)
}
guard let attachmentDataSource = dataSource else {
owsFail("dataSource was unexpectedly nil")
owsFailDebug("dataSource was unexpectedly nil")
return
}

View File

@ -20,7 +20,7 @@ import Foundation
}
Logger.error("findFrontmostViewController: \(window)")
guard let viewController = window.rootViewController else {
owsFail("Missing root view controller.")
owsFailDebug("Missing root view controller.")
return nil
}
return viewController.findFrontmostViewController(ignoringAlerts)

View File

@ -35,10 +35,10 @@ class AddContactShareToExistingContactViewController: ContactsPicker, ContactsPi
// MARK: - ContactsPickerDelegate
func contactsPicker(_: ContactsPicker, contactFetchDidFail error: NSError) {
owsFail("with error: \(error)")
owsFailDebug("with error: \(error)")
guard let navigationController = self.navigationController else {
owsFail("navigationController was unexpectedly nil")
owsFailDebug("navigationController was unexpectedly nil")
return
}
@ -48,7 +48,7 @@ class AddContactShareToExistingContactViewController: ContactsPicker, ContactsPi
func contactsPickerDidCancel(_: ContactsPicker) {
Logger.debug("")
guard let navigationController = self.navigationController else {
owsFail("navigationController was unexpectedly nil")
owsFailDebug("navigationController was unexpectedly nil")
return
}
@ -60,11 +60,11 @@ class AddContactShareToExistingContactViewController: ContactsPicker, ContactsPi
let contactsManager = Environment.current().contactsManager
guard let oldCNContact = contactsManager?.cnContact(withId: oldContact.cnContactId) else {
owsFail("could not load old CNContact.")
owsFailDebug("could not load old CNContact.")
return
}
guard let newCNContact = OWSContacts.systemContact(for: self.contactShare.dbRecord, imageData: self.contactShare.avatarImageData) else {
owsFail("could not load new CNContact.")
owsFailDebug("could not load new CNContact.")
return
}
merge(oldCNContact: oldCNContact, newCNContact: newCNContact)
@ -92,10 +92,10 @@ class AddContactShareToExistingContactViewController: ContactsPicker, ContactsPi
func contactsPicker(_: ContactsPicker, didSelectMultipleContacts contacts: [Contact]) {
Logger.debug("")
owsFail("only supports single contact select")
owsFailDebug("only supports single contact select")
guard let navigationController = self.navigationController else {
owsFail("navigationController was unexpectedly nil")
owsFailDebug("navigationController was unexpectedly nil")
return
}
@ -112,7 +112,7 @@ class AddContactShareToExistingContactViewController: ContactsPicker, ContactsPi
Logger.debug("")
guard let navigationController = self.navigationController else {
owsFail("navigationController was unexpectedly nil")
owsFailDebug("navigationController was unexpectedly nil")
return
}
@ -129,7 +129,7 @@ class AddContactShareToExistingContactViewController: ContactsPicker, ContactsPi
// Note this happens for *cancel* and for *done*. Unfortunately, I don't know of a way to detect the difference
// between the two, since both just call this method.
guard let myIndex = navigationController.viewControllers.index(of: self) else {
owsFail("myIndex was unexpectedly nil")
owsFailDebug("myIndex was unexpectedly nil")
navigationController.popViewController(animated: true)
navigationController.popViewController(animated: true)
return

View File

@ -118,7 +118,7 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver,
return true
} else {
guard let portDescription = audioSource.portDescription else {
owsFail("Only built in speaker should be lacking a port description.")
owsFailDebug("Only built in speaker should be lacking a port description.")
return false
}

View File

@ -108,7 +108,7 @@ class ColorPickerViewController: UIViewController, UIPickerViewDelegate, UIPicke
public func pickerView(_ pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusing view: UIView?) -> UIView {
guard let color = colors[safe: row] else {
owsFail("color was unexpectedly nil")
owsFailDebug("color was unexpectedly nil")
return ColorView(color: .white)
}
@ -120,7 +120,7 @@ class ColorPickerViewController: UIViewController, UIPickerViewDelegate, UIPicke
var currentColor: UIColor {
let index = pickerView.selectedRow(inComponent: 0)
guard let color = self.colors[safe: index] else {
owsFail("index was unexpectedly nil")
owsFailDebug("index was unexpectedly nil")
return UIColor.white
}
@ -130,7 +130,7 @@ class ColorPickerViewController: UIViewController, UIPickerViewDelegate, UIPicke
@objc
public func didTapSave() {
guard let colorName = UIColor.ows_conversationColorName(color: self.currentColor) else {
owsFail("colorName was unexpectedly nil")
owsFailDebug("colorName was unexpectedly nil")
self.delegate?.colorPickerDidCancel(self)
return
}

View File

@ -57,7 +57,7 @@ public class ContactShareViewHelper: NSObject, CNContactViewControllerDelegate {
// want to let the user select if there's more than one.
let phoneNumbers = contactShare.systemContactsWithSignalAccountPhoneNumbers(contactsManager)
guard phoneNumbers.count > 0 else {
owsFail("missing Signal recipient id.")
owsFailDebug("missing Signal recipient id.")
return
}
guard phoneNumbers.count > 1 else {
@ -82,7 +82,7 @@ public class ContactShareViewHelper: NSObject, CNContactViewControllerDelegate {
}
let phoneNumbers = contactShare.e164PhoneNumbers()
guard phoneNumbers.count > 0 else {
owsFail("no phone numbers.")
owsFailDebug("no phone numbers.")
return
}
@ -143,12 +143,12 @@ public class ContactShareViewHelper: NSObject, CNContactViewControllerDelegate {
private func presentNewContactView(contactShare: ContactShareViewModel, fromViewController: UIViewController) {
guard contactsManager.supportsContactEditing else {
owsFail("Contact editing not supported")
owsFailDebug("Contact editing not supported")
return
}
guard let systemContact = OWSContacts.systemContact(for: contactShare.dbRecord, imageData: contactShare.avatarImageData) else {
owsFail("Could not derive system contact.")
owsFailDebug("Could not derive system contact.")
return
}
@ -172,7 +172,7 @@ public class ContactShareViewHelper: NSObject, CNContactViewControllerDelegate {
private func presentSelectAddToExistingContactView(contactShare: ContactShareViewModel, fromViewController: UIViewController) {
guard contactsManager.supportsContactEditing else {
owsFail("Contact editing not supported")
owsFailDebug("Contact editing not supported")
return
}
@ -182,7 +182,7 @@ public class ContactShareViewHelper: NSObject, CNContactViewControllerDelegate {
}
guard let navigationController = fromViewController.navigationController else {
owsFail("missing navigationController")
owsFailDebug("missing navigationController")
return
}
@ -196,7 +196,7 @@ public class ContactShareViewHelper: NSObject, CNContactViewControllerDelegate {
Logger.info("")
guard let delegate = delegate else {
owsFail("missing delegate")
owsFailDebug("missing delegate")
return
}
@ -207,7 +207,7 @@ public class ContactShareViewHelper: NSObject, CNContactViewControllerDelegate {
Logger.info("")
guard let delegate = delegate else {
owsFail("missing delegate")
owsFailDebug("missing delegate")
return
}

View File

@ -79,7 +79,7 @@ class ContactViewController: OWSViewController, ContactShareViewHelperDelegate {
super.viewWillAppear(animated)
guard let navigationController = self.navigationController else {
owsFail("navigationController was unexpectedly nil")
owsFailDebug("navigationController was unexpectedly nil")
return
}
@ -103,7 +103,7 @@ class ContactViewController: OWSViewController, ContactShareViewHelperDelegate {
// animation glitch where the navigation bar for this view controller starts to appear while
// the whole nav stack is about to be obscured by the modal we are presenting.
guard let postDismissNavigationController = self.postDismissNavigationController else {
owsFail("postDismissNavigationController was unexpectedly nil")
owsFailDebug("postDismissNavigationController was unexpectedly nil")
return
}
@ -157,7 +157,7 @@ class ContactViewController: OWSViewController, ContactShareViewHelperDelegate {
AssertIsOnMainThread()
guard let rootView = self.view else {
owsFail("missing root view.")
owsFailDebug("missing root view.")
return
}
@ -223,7 +223,7 @@ class ContactViewController: OWSViewController, ContactShareViewHelperDelegate {
let backIconName = (CurrentAppContext().isRTL ? "system_disclosure_indicator" : "system_disclosure_indicator_rtl")
guard let backIconImage = UIImage(named: backIconName) else {
owsFail("missing icon.")
owsFailDebug("missing icon.")
return topView
}
let backIconView = UIImageView(image: backIconImage.withRenderingMode(.alwaysTemplate))
@ -438,7 +438,7 @@ class ContactViewController: OWSViewController, ContactShareViewHelperDelegate {
circleView.autoHCenterInSuperview()
guard let image = UIImage(named: imageName) else {
owsFail("missing image.")
owsFailDebug("missing image.")
return button
}
let imageView = UIImageView(image: image.withRenderingMode(.alwaysTemplate))
@ -527,7 +527,7 @@ class ContactViewController: OWSViewController, ContactShareViewHelperDelegate {
Logger.info("")
guard let navigationController = self.navigationController else {
owsFail("navigationController was unexpectedly nil")
owsFailDebug("navigationController was unexpectedly nil")
return
}
@ -573,7 +573,7 @@ class ContactViewController: OWSViewController, ContactShareViewHelperDelegate {
Logger.info("")
guard let url = NSURL(string: "tel:\(phoneNumber.phoneNumber)") else {
owsFail("could not open phone number.")
owsFailDebug("could not open phone number.")
return
}
UIApplication.shared.openURL(url as URL)
@ -601,7 +601,7 @@ class ContactViewController: OWSViewController, ContactShareViewHelperDelegate {
Logger.info("")
guard let url = NSURL(string: "mailto:\(email.email)") else {
owsFail("could not open email.")
owsFailDebug("could not open email.")
return
}
UIApplication.shared.openURL(url as URL)
@ -632,13 +632,13 @@ class ContactViewController: OWSViewController, ContactShareViewHelperDelegate {
let mapAddress = formatAddressForQuery(address: address)
guard let escapedMapAddress = mapAddress.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) else {
owsFail("could not open address.")
owsFailDebug("could not open address.")
return
}
// Note that we use "q" (i.e. query) rather than "address" since we can't assume
// this is a well-formed address.
guard let url = URL(string: "http://maps.apple.com/?q=\(escapedMapAddress)") else {
owsFail("could not open address.")
owsFailDebug("could not open address.")
return
}

View File

@ -247,7 +247,7 @@ public class ContactsPicker: OWSViewController, UITableViewDelegate, UITableView
open func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(withIdentifier: contactCellReuseIdentifier, for: indexPath) as? ContactCell else {
owsFail("cell had unexpected type")
owsFailDebug("cell had unexpected type")
return UITableViewCell()
}

View File

@ -499,7 +499,7 @@ import SignalMessaging
let scaledImage = UIGraphicsGetImageFromCurrentImageContext()
if scaledImage == nil {
owsFail("could not generate dst image.")
owsFailDebug("could not generate dst image.")
}
UIGraphicsEndImageContext()
return scaledImage

View File

@ -22,7 +22,7 @@ class DebugUICalling: DebugUIPage {
override func section(thread aThread: TSThread?) -> OWSTableSection? {
guard let thread = aThread as? TSContactThread else {
owsFail("Calling is only valid for contact thread, got thread: \(String(describing: aThread))")
owsFailDebug("Calling is only valid for contact thread, got thread: \(String(describing: aThread))")
return nil
}
@ -37,7 +37,7 @@ class DebugUICalling: DebugUIPage {
hangupBuilder.setId(kFakeCallId)
hangupMessage = try hangupBuilder.build()
} catch {
owsFail("could not build proto")
owsFailDebug("could not build proto")
return
}
let callMessage = OWSOutgoingCallMessage(thread: thread, hangupMessage: hangupMessage)
@ -58,7 +58,7 @@ class DebugUICalling: DebugUIPage {
busyBuilder.setId(kFakeCallId)
busyMessage = try busyBuilder.build()
} catch {
owsFail("Couldn't build proto")
owsFailDebug("Couldn't build proto")
return
}

View File

@ -65,7 +65,7 @@
return try fileManager.contentsOfDirectory(at: fileURL,
includingPropertiesForKeys: resourceKeys)
} catch {
owsFail("contentsOfDirectory(\(fileURL) failed with error: \(error)")
owsFailDebug("contentsOfDirectory(\(fileURL) failed with error: \(error)")
return []
}
}()
@ -74,13 +74,13 @@
let fileIcon: String = {
do {
guard let isDirectory = try fileInDirectory.resourceValues(forKeys: Set(resourceKeys)).isDirectory else {
owsFail("unable to check isDirectory for file: \(fileInDirectory)")
owsFailDebug("unable to check isDirectory for file: \(fileInDirectory)")
return ""
}
return isDirectory ? "📁 " : ""
} catch {
owsFail("failed to check isDirectory for file: \(fileInDirectory) with error: \(error)")
owsFailDebug("failed to check isDirectory for file: \(fileInDirectory) with error: \(error)")
return ""
}
}()
@ -107,7 +107,7 @@
}
}
} catch {
owsFail("failed getting attributes for file at path: \(fileURL)")
owsFailDebug("failed getting attributes for file at path: \(fileURL)")
return []
}
}()
@ -127,7 +127,7 @@
alert.addAction(OWSAlerts.cancelAction)
alert.addAction(UIAlertAction(title: "Rename \(strongSelf.fileURL.lastPathComponent)", style: .default) { _ in
guard let textField = alert.textFields?.first else {
owsFail("missing text field")
owsFailDebug("missing text field")
return
}
@ -144,7 +144,7 @@
Logger.debug("\(strongSelf) moved \(strongSelf.fileURL) -> \(newURL)")
strongSelf.navigationController?.popViewController(animated: true)
} catch {
owsFail("\(strongSelf) failed to move \(strongSelf.fileURL) -> \(newURL) with error: \(error)")
owsFailDebug("\(strongSelf) failed to move \(strongSelf.fileURL) -> \(newURL) with error: \(error)")
}
})
@ -172,7 +172,7 @@
alert.addAction(OWSAlerts.cancelAction)
alert.addAction(UIAlertAction(title: "Moving \(filename)", style: .default) { _ in
guard let textField = alert.textFields?.first else {
owsFail("missing text field")
owsFailDebug("missing text field")
return
}
@ -189,7 +189,7 @@
Logger.debug("\(strongSelf) moved \(fileURL) -> \(newURL)")
strongSelf.navigationController?.popViewController(animated: true)
} catch {
owsFail("\(strongSelf) failed to move \(fileURL) -> \(newURL) with error: \(error)")
owsFailDebug("\(strongSelf) failed to move \(fileURL) -> \(newURL) with error: \(error)")
}
})
@ -212,7 +212,7 @@
try strongSelf.fileManager.removeItem(atPath: strongSelf.fileURL.path)
strongSelf.navigationController?.popViewController(animated: true)
} catch {
owsFail("failed to remove item: \(strongSelf.fileURL) with error: \(error)")
owsFailDebug("failed to remove item: \(strongSelf.fileURL) with error: \(error)")
}
}
},
@ -248,7 +248,7 @@
let attributes = try strongSelf.fileManager.attributesOfItem(atPath: fileURL.path)
return attributes[FileAttributeKey.protectionKey] as? FileProtectionType
} catch {
owsFail("failed to get current file protection for file: \(fileURL)")
owsFailDebug("failed to get current file protection for file: \(fileURL)")
return nil
}
}()
@ -267,7 +267,7 @@
Logger.debug("updated file protection at path:\(fileURL.path) to: \(protection.rawValue)")
strongSelf.updateContents()
} catch {
owsFail("failed to update file protection at path:\(fileURL.path) with error: \(error)")
owsFailDebug("failed to update file protection at path:\(fileURL.path) with error: \(error)")
}
})
}
@ -290,7 +290,7 @@
alert.addAction(OWSAlerts.cancelAction)
alert.addAction(UIAlertAction(title: "Create", style: .default) { _ in
guard let textField = alert.textFields?.first else {
owsFail("missing text field")
owsFailDebug("missing text field")
return
}
@ -328,7 +328,7 @@
alert.addAction(OWSAlerts.cancelAction)
alert.addAction(UIAlertAction(title: "Create", style: .default) { _ in
guard let textField = alert.textFields?.first else {
owsFail("missing text field")
owsFailDebug("missing text field")
return
}
@ -344,7 +344,7 @@
try strongSelf.fileManager.createDirectory(atPath: newPath, withIntermediateDirectories: false)
strongSelf.updateContents()
} catch {
owsFail("Failed to create dir: \(newPath) with error: \(error)")
owsFailDebug("Failed to create dir: \(newPath) with error: \(error)")
}
})

View File

@ -31,7 +31,7 @@ class DebugUINotifications: DebugUIPage {
override func section(thread aThread: TSThread?) -> OWSTableSection? {
guard let thread = aThread else {
owsFail("Notifications must specify thread.")
owsFailDebug("Notifications must specify thread.")
return nil
}
@ -46,17 +46,17 @@ class DebugUINotifications: DebugUIPage {
Logger.info("dispatching")
OWSPrimaryStorage.shared().newDatabaseConnection().read { (transaction) in
guard let viewTransaction = transaction.ext(TSMessageDatabaseViewExtensionName) as? YapDatabaseViewTransaction else {
owsFail("unable to build view transaction")
owsFailDebug("unable to build view transaction")
return
}
guard let threadId = thread.uniqueId else {
owsFail("thread had no uniqueId")
owsFailDebug("thread had no uniqueId")
return
}
guard let incomingMessage = viewTransaction.lastObject(inGroup: threadId) as? TSIncomingMessage else {
owsFail("last message was not an incoming message.")
owsFailDebug("last message was not an incoming message.")
return
}
Logger.info("notifying user of incoming message")

View File

@ -45,7 +45,7 @@ class DebugUIProfile: DebugUIPage {
strongSelf.messageSender.sendPromise(message: message).then {
Logger.info("Successfully sent profile key message to thread: \(String(describing: aThread))")
}.catch { _ in
owsFail("Failed to send profile key message to thread: \(String(describing: aThread))")
owsFailDebug("Failed to send profile key message to thread: \(String(describing: aThread))")
}
}
]

View File

@ -45,7 +45,7 @@ private class IntroducingCustomNotificationAudioExperienceUpgradeViewController:
// dismiss the modally presented view controller, then proceed.
self.experienceUpgradesPageViewController.dismiss(animated: true) {
guard let fromViewController = UIApplication.shared.frontmostViewController else {
owsFail("frontmostViewController was unexectedly nil")
owsFailDebug("frontmostViewController was unexectedly nil")
return
}
@ -107,7 +107,7 @@ private class IntroducingCustomNotificationAudioExperienceUpgradeViewController:
Logger.debug("")
guard let buttonAction = self.buttonAction else {
owsFail("button action was nil")
owsFailDebug("button action was nil")
return
}
@ -155,7 +155,7 @@ private class IntroductingReadReceiptsExperienceUpgradeViewController: Experienc
// dismiss the modally presented view controller, then proceed.
self.experienceUpgradesPageViewController.dismiss(animated: true) {
guard let fromViewController = UIApplication.shared.frontmostViewController as? HomeViewController else {
owsFail("unexpected frontmostViewController: \(String(describing: UIApplication.shared.frontmostViewController))")
owsFailDebug("unexpected frontmostViewController: \(String(describing: UIApplication.shared.frontmostViewController))")
return
}
@ -217,7 +217,7 @@ private class IntroductingReadReceiptsExperienceUpgradeViewController: Experienc
Logger.debug("")
guard let buttonAction = self.buttonAction else {
owsFail("button action was nil")
owsFailDebug("button action was nil")
return
}
@ -349,7 +349,7 @@ private class IntroductingProfilesExperienceUpgradeViewController: ExperienceUpg
// dismiss the modally presented view controller, then proceed.
experienceUpgradesPageViewController.dismiss(animated: true) {
guard let fromViewController = UIApplication.shared.frontmostViewController as? HomeViewController else {
owsFail("unexpected frontmostViewController: \(String(describing: UIApplication.shared.frontmostViewController))")
owsFailDebug("unexpected frontmostViewController: \(String(describing: UIApplication.shared.frontmostViewController))")
return
}
ProfileViewController.presentForUpgradeOrNag(from: fromViewController)
@ -515,7 +515,7 @@ public class ExperienceUpgradesPageViewController: OWSViewController, UIPageView
@objc public override func viewDidLoad() {
guard let firstViewController = allViewControllers.first else {
owsFail("no pages to show.")
owsFailDebug("no pages to show.")
dismiss(animated: true)
return
}
@ -601,7 +601,7 @@ public class ExperienceUpgradesPageViewController: OWSViewController, UIPageView
public func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
Logger.debug("")
guard let currentIndex = self.viewControllerIndexes[viewController] else {
owsFail("unknown view controller: \(viewController)")
owsFailDebug("unknown view controller: \(viewController)")
return nil
}
@ -616,7 +616,7 @@ public class ExperienceUpgradesPageViewController: OWSViewController, UIPageView
public func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {
Logger.debug("")
guard let currentIndex = self.viewControllerIndexes[viewController] else {
owsFail("unknown view controller: \(viewController)")
owsFailDebug("unknown view controller: \(viewController)")
return nil
}
@ -653,7 +653,7 @@ public class ExperienceUpgradesPageViewController: OWSViewController, UIPageView
return
}
guard let identifier = ExperienceUpgradeId(rawValue: uniqueId) else {
owsFail("unknown experience upgrade. skipping")
owsFailDebug("unknown experience upgrade. skipping")
return
}

View File

@ -141,7 +141,7 @@ class GifPickerCell: UICollectionViewCell {
success: { [weak self] assetRequest, asset in
guard let strongSelf = self else { return }
if assetRequest != nil && assetRequest != strongSelf.stillAssetRequest {
owsFail("Obsolete request callback.")
owsFailDebug("Obsolete request callback.")
return
}
strongSelf.clearStillAssetRequest()
@ -151,7 +151,7 @@ class GifPickerCell: UICollectionViewCell {
failure: { [weak self] assetRequest in
guard let strongSelf = self else { return }
if assetRequest != strongSelf.stillAssetRequest {
owsFail("Obsolete request callback.")
owsFailDebug("Obsolete request callback.")
return
}
strongSelf.clearStillAssetRequest()
@ -167,7 +167,7 @@ class GifPickerCell: UICollectionViewCell {
success: { [weak self] assetRequest, asset in
guard let strongSelf = self else { return }
if assetRequest != nil && assetRequest != strongSelf.animatedAssetRequest {
owsFail("Obsolete request callback.")
owsFailDebug("Obsolete request callback.")
return
}
// If we have the animated asset, we don't need the still asset.
@ -178,7 +178,7 @@ class GifPickerCell: UICollectionViewCell {
failure: { [weak self] assetRequest in
guard let strongSelf = self else { return }
if assetRequest != strongSelf.animatedAssetRequest {
owsFail("Obsolete request callback.")
owsFailDebug("Obsolete request callback.")
return
}
strongSelf.clearAnimatedAssetRequest()
@ -197,7 +197,7 @@ class GifPickerCell: UICollectionViewCell {
return
}
guard let image = YYImage(contentsOfFile: asset.filePath) else {
owsFail("could not load asset.")
owsFailDebug("could not load asset.")
clearViewState()
return
}
@ -208,7 +208,7 @@ class GifPickerCell: UICollectionViewCell {
imageView.ows_autoPinToSuperviewEdges()
}
guard let imageView = imageView else {
owsFail("missing imageview.")
owsFailDebug("missing imageview.")
clearViewState()
return
}
@ -240,7 +240,7 @@ class GifPickerCell: UICollectionViewCell {
public func requestRenditionForSending() -> Promise<GiphyAsset> {
guard let renditionForSending = self.renditionForSending else {
owsFail("renditionForSending was unexpectedly nil")
owsFailDebug("renditionForSending was unexpectedly nil")
return Promise(error: GiphyError.assertionError(description: "renditionForSending was unexpectedly nil"))
}

View File

@ -99,7 +99,7 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
func ensureCellState() {
for cell in self.collectionView.visibleCells {
guard let cell = cell as? GifPickerCell else {
owsFail("unexpected cell.")
owsFailDebug("unexpected cell.")
return
}
cell.ensureCellState()
@ -236,15 +236,15 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
private func updateContents() {
guard let noResultsView = self.noResultsView else {
owsFail("Missing noResultsView")
owsFailDebug("Missing noResultsView")
return
}
guard let searchErrorView = self.searchErrorView else {
owsFail("Missing searchErrorView")
owsFailDebug("Missing searchErrorView")
return
}
guard let activityIndicator = self.activityIndicator else {
owsFail("Missing activityIndicator")
owsFailDebug("Missing activityIndicator")
return
}
@ -307,7 +307,7 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
let imageInfo = imageInfos[indexPath.row]
guard let gifCell = cell as? GifPickerCell else {
owsFail("Unexpected cell type.")
owsFailDebug("Unexpected cell type.")
return cell
}
gifCell.imageInfo = imageInfo
@ -319,7 +319,7 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
guard let cell = collectionView.cellForItem(at: indexPath) as? GifPickerCell else {
owsFail("unexpected cell.")
owsFailDebug("unexpected cell.")
return
}
@ -330,7 +330,7 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
}
guard self.hasSelectedCell == false else {
owsFail("Already selected cell")
owsFailDebug("Already selected cell")
return
}
self.hasSelectedCell = true
@ -370,7 +370,7 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
let filePath = asset.filePath
guard let dataSource = DataSourcePath.dataSource(withFilePath: filePath,
shouldDeleteOnDeallocation: false) else {
owsFail("couldn't load asset.")
owsFailDebug("couldn't load asset.")
return
}
let attachment = SignalAttachment.attachment(dataSource: dataSource, dataUTI: asset.rendition.utiType, imageQuality: .original)
@ -402,7 +402,7 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
public func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
guard let cell = cell as? GifPickerCell else {
owsFail("unexpected cell.")
owsFailDebug("unexpected cell.")
return
}
// We only want to load the cells which are on-screen.
@ -411,7 +411,7 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
public func collectionView(_ collectionView: UICollectionView, didEndDisplaying cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
guard let cell = cell as? GifPickerCell else {
owsFail("unexpected cell.")
owsFailDebug("unexpected cell.")
return
}
cell.isCellVisible = false

View File

@ -122,17 +122,17 @@ class ConversationSearchViewController: UITableViewController {
tableView.deselectRow(at: indexPath, animated: false)
guard let searchSection = SearchSection(rawValue: indexPath.section) else {
owsFail("unknown section selected.")
owsFailDebug("unknown section selected.")
return
}
switch searchSection {
case .noResults:
owsFail("shouldn't be able to tap 'no results' section")
owsFailDebug("shouldn't be able to tap 'no results' section")
case .conversations:
let sectionResults = searchResultSet.conversations
guard let searchResult = sectionResults[safe: indexPath.row] else {
owsFail("unknown row selected.")
owsFailDebug("unknown row selected.")
return
}
@ -142,7 +142,7 @@ class ConversationSearchViewController: UITableViewController {
case .contacts:
let sectionResults = searchResultSet.contacts
guard let searchResult = sectionResults[safe: indexPath.row] else {
owsFail("unknown row selected.")
owsFailDebug("unknown row selected.")
return
}
@ -151,7 +151,7 @@ class ConversationSearchViewController: UITableViewController {
case .messages:
let sectionResults = searchResultSet.messages
guard let searchResult = sectionResults[safe: indexPath.row] else {
owsFail("unknown row selected.")
owsFailDebug("unknown row selected.")
return
}
@ -167,7 +167,7 @@ class ConversationSearchViewController: UITableViewController {
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
guard let searchSection = SearchSection(rawValue: section) else {
owsFail("unknown section: \(section)")
owsFailDebug("unknown section: \(section)")
return 0
}
@ -192,12 +192,12 @@ class ConversationSearchViewController: UITableViewController {
switch searchSection {
case .noResults:
guard let cell = tableView.dequeueReusableCell(withIdentifier: EmptySearchResultCell.reuseIdentifier) as? EmptySearchResultCell else {
owsFail("cell was unexpectedly nil")
owsFailDebug("cell was unexpectedly nil")
return UITableViewCell()
}
guard indexPath.row == 0 else {
owsFail("searchResult was unexpected index")
owsFailDebug("searchResult was unexpected index")
return UITableViewCell()
}
@ -208,36 +208,36 @@ class ConversationSearchViewController: UITableViewController {
return cell
case .conversations:
guard let cell = tableView.dequeueReusableCell(withIdentifier: HomeViewCell.cellReuseIdentifier()) as? HomeViewCell else {
owsFail("cell was unexpectedly nil")
owsFailDebug("cell was unexpectedly nil")
return UITableViewCell()
}
guard let searchResult = self.searchResultSet.conversations[safe: indexPath.row] else {
owsFail("searchResult was unexpectedly nil")
owsFailDebug("searchResult was unexpectedly nil")
return UITableViewCell()
}
cell.configure(withThread: searchResult.thread, contactsManager: contactsManager, blockedPhoneNumber: self.blockedPhoneNumberSet)
return cell
case .contacts:
guard let cell = tableView.dequeueReusableCell(withIdentifier: ContactTableViewCell.reuseIdentifier()) as? ContactTableViewCell else {
owsFail("cell was unexpectedly nil")
owsFailDebug("cell was unexpectedly nil")
return UITableViewCell()
}
guard let searchResult = self.searchResultSet.contacts[safe: indexPath.row] else {
owsFail("searchResult was unexpectedly nil")
owsFailDebug("searchResult was unexpectedly nil")
return UITableViewCell()
}
cell.configure(withRecipientId: searchResult.signalAccount.recipientId, contactsManager: contactsManager)
return cell
case .messages:
guard let cell = tableView.dequeueReusableCell(withIdentifier: HomeViewCell.cellReuseIdentifier()) as? HomeViewCell else {
owsFail("cell was unexpectedly nil")
owsFailDebug("cell was unexpectedly nil")
return UITableViewCell()
}
guard let searchResult = self.searchResultSet.messages[safe: indexPath.row] else {
owsFail("searchResult was unexpectedly nil")
owsFailDebug("searchResult was unexpectedly nil")
return UITableViewCell()
}
@ -247,7 +247,7 @@ class ConversationSearchViewController: UITableViewController {
if let messageDate = searchResult.messageDate {
overrideDate = messageDate
} else {
owsFail("message search result is missing message timestamp")
owsFailDebug("message search result is missing message timestamp")
}
// Note that we only use the snippet for message results,
@ -260,7 +260,7 @@ class ConversationSearchViewController: UITableViewController {
NSAttributedStringKey.foregroundColor: Theme.secondaryColor
])
} else {
owsFail("message search result is missing message snippet")
owsFailDebug("message search result is missing message snippet")
}
}
@ -309,7 +309,7 @@ class ConversationSearchViewController: UITableViewController {
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
guard let searchSection = SearchSection(rawValue: section) else {
owsFail("unknown section: \(section)")
owsFailDebug("unknown section: \(section)")
return nil
}
@ -387,7 +387,7 @@ class ConversationSearchViewController: UITableViewController {
guard let strongSelf = self else { return }
guard let results = searchResults else {
owsFail("\(strongSelf.logTag) in \(#function) searchResults was unexpectedly nil")
owsFailDebug("\(strongSelf.logTag) in \(#function) searchResults was unexpectedly nil")
return
}

View File

@ -141,7 +141,7 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
}
func contactsPicker(_: ContactsPicker, didSelectContact contact: Contact) {
owsFail("InviteFlow only supports multi-select")
owsFailDebug("InviteFlow only supports multi-select")
self.presentingViewController.dismiss(animated: true)
}

View File

@ -35,7 +35,7 @@ public struct MediaGalleryItem: Equatable, Hashable {
var thumbnailImage: UIImage {
guard let image = attachmentStream.thumbnailImage() else {
owsFail("unexpectedly unable to build attachment thumbnail")
owsFailDebug("unexpectedly unable to build attachment thumbnail")
return UIImage()
}
@ -44,7 +44,7 @@ public struct MediaGalleryItem: Equatable, Hashable {
var fullSizedImage: UIImage {
guard let image = attachmentStream.image() else {
owsFail("unexpectedly unable to build attachment image")
owsFailDebug("unexpectedly unable to build attachment image")
return UIImage()
}
@ -282,7 +282,7 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
}
guard let initialDetailItem = galleryItem else {
owsFail("unexpectedly failed to build initialDetailItem.")
owsFailDebug("unexpectedly failed to build initialDetailItem.")
return
}
@ -329,7 +329,7 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
self.view.alpha = 0.0
guard let detailView = pageViewController.view else {
owsFail("detailView was unexpectedly nil")
owsFailDebug("detailView was unexpectedly nil")
return
}
@ -454,7 +454,7 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
//
guard let pageViewController = self.pageViewController else {
owsFail("pageViewController was unexpectedly nil")
owsFailDebug("pageViewController was unexpectedly nil")
self.dismiss(animated: true)
return
@ -473,7 +473,7 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
UIApplication.shared.isStatusBarHidden = false
guard let detailView = mediaPageViewController.view else {
owsFail("detailView was unexpectedly nil")
owsFailDebug("detailView was unexpectedly nil")
self.presentingViewController?.dismiss(animated: false, completion: completion)
return
}
@ -520,7 +520,7 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
options: .curveEaseInOut,
animations: {
guard let replacingView = self.replacingView else {
owsFail("replacingView was unexpectedly nil")
owsFailDebug("replacingView was unexpectedly nil")
self.presentingViewController?.dismiss(animated: false, completion: completion)
return
}
@ -533,7 +533,7 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
})
} else {
guard let replacingView = self.replacingView else {
owsFail("replacingView was unexpectedly nil")
owsFailDebug("replacingView was unexpectedly nil")
self.presentingViewController?.dismiss(animated: false, completion: completion)
return
}
@ -549,12 +549,12 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
}
guard let originRect = self.originRect else {
owsFail("originRect was unexpectedly nil")
owsFailDebug("originRect was unexpectedly nil")
return
}
guard let presentationSuperview = self.presentationView.superview else {
owsFail("presentationView.superview was unexpectedly nil")
owsFailDebug("presentationView.superview was unexpectedly nil")
return
}
@ -613,7 +613,7 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
func buildGalleryItem(message: TSMessage, transaction: YapDatabaseReadTransaction) -> MediaGalleryItem? {
guard let attachmentStream = message.attachment(with: transaction) as? TSAttachmentStream else {
owsFail("attachment was unexpectedly empty")
owsFailDebug("attachment was unexpectedly empty")
return nil
}
@ -696,7 +696,7 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
}
guard let item: MediaGalleryItem = self.buildGalleryItem(message: message, transaction: transaction) else {
owsFail("unexpectedly failed to buildGalleryItem")
owsFailDebug("unexpectedly failed to buildGalleryItem")
return
}
@ -795,40 +795,40 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
for item in items {
guard let itemIndex = galleryItems.index(of: item) else {
owsFail("removing unknown item.")
owsFailDebug("removing unknown item.")
return
}
self.galleryItems.remove(at: itemIndex)
guard let sectionIndex = sectionDates.index(where: { $0 == item.galleryDate }) else {
owsFail("item with unknown date.")
owsFailDebug("item with unknown date.")
return
}
guard var sectionItems = self.sections[item.galleryDate] else {
owsFail("item with unknown section")
owsFailDebug("item with unknown section")
return
}
guard let sectionRowIndex = sectionItems.index(of: item) else {
owsFail("item with unknown sectionRowIndex")
owsFailDebug("item with unknown sectionRowIndex")
return
}
// We need to calculate the index of the deleted item with respect to it's original position.
guard let originalSectionIndex = originalSectionDates.index(where: { $0 == item.galleryDate }) else {
owsFail("item with unknown date.")
owsFailDebug("item with unknown date.")
return
}
guard let originalSectionItems = originalSections[item.galleryDate] else {
owsFail("item with unknown section")
owsFailDebug("item with unknown section")
return
}
guard let originalSectionRowIndex = originalSectionItems.index(of: item) else {
owsFail("item with unknown sectionRowIndex")
owsFailDebug("item with unknown sectionRowIndex")
return
}
@ -858,7 +858,7 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
self.ensureGalleryItemsLoaded(.after, item: currentItem, amount: kGallerySwipeLoadBatchSize)
guard let currentIndex = galleryItems.index(of: currentItem) else {
owsFail("currentIndex was unexpectedly nil")
owsFailDebug("currentIndex was unexpectedly nil")
return nil
}
@ -882,7 +882,7 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
self.ensureGalleryItemsLoaded(.before, item: currentItem, amount: kGallerySwipeLoadBatchSize)
guard let currentIndex = galleryItems.index(of: currentItem) else {
owsFail("currentIndex was unexpectedly nil")
owsFailDebug("currentIndex was unexpectedly nil")
return nil
}

View File

@ -54,7 +54,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
private func setCurrentItem(_ item: MediaGalleryItem, direction: UIPageViewControllerNavigationDirection, animated isAnimated: Bool) {
guard let galleryPage = self.buildGalleryPage(galleryItem: item) else {
owsFail("unexpetedly unable to build new gallery page")
owsFailDebug("unexpetedly unable to build new gallery page")
return
}
@ -107,7 +107,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
self.delegate = self
guard let initialPage = self.buildGalleryPage(galleryItem: initialItem) else {
owsFail("unexpetedly unable to build initial gallery item")
owsFailDebug("unexpetedly unable to build initial gallery item")
return
}
self.initialPage = initialPage
@ -219,7 +219,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
currentViewController.stopAnyVideo()
guard let mediaGalleryDataSource = self.mediaGalleryDataSource else {
owsFail("mediaGalleryDataSource was unexpectedly nil")
owsFailDebug("mediaGalleryDataSource was unexpectedly nil")
return
}
mediaGalleryDataSource.showAllMedia(focusedItem: currentItem)
@ -258,7 +258,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
// TODO do we still need this? seems like a vestige
// from when media detail view was used for attachment approval
if self.footerBar == nil {
owsFail("No footer bar visible.")
owsFailDebug("No footer bar visible.")
return
}
@ -291,7 +291,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
@objc
public func didPressShare(_ sender: Any) {
guard let currentViewController = self.viewControllers?[0] as? MediaDetailViewController else {
owsFail("currentViewController was unexpectedly nil")
owsFailDebug("currentViewController was unexpectedly nil")
return
}
currentViewController.didPressShare(sender)
@ -300,12 +300,12 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
@objc
public func didPressDelete(_ sender: Any) {
guard let currentViewController = self.viewControllers?[0] as? MediaDetailViewController else {
owsFail("currentViewController was unexpectedly nil")
owsFailDebug("currentViewController was unexpectedly nil")
return
}
guard let mediaGalleryDataSource = self.mediaGalleryDataSource else {
owsFail("mediaGalleryDataSource was unexpectedly nil")
owsFailDebug("mediaGalleryDataSource was unexpectedly nil")
return
}
@ -327,7 +327,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
Logger.debug("")
guard let currentItem = self.currentItem else {
owsFail("currentItem was unexpectedly nil")
owsFailDebug("currentItem was unexpectedly nil")
return
}
@ -361,7 +361,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
@objc
public func didPressPlayBarButton(_ sender: Any) {
guard let currentViewController = self.viewControllers?[0] as? MediaDetailViewController else {
owsFail("currentViewController was unexpectedly nil")
owsFailDebug("currentViewController was unexpectedly nil")
return
}
currentViewController.didPressPlayBarButton(sender)
@ -370,7 +370,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
@objc
public func didPressPauseBarButton(_ sender: Any) {
guard let currentViewController = self.viewControllers?[0] as? MediaDetailViewController else {
owsFail("currentViewController was unexpectedly nil")
owsFailDebug("currentViewController was unexpectedly nil")
return
}
currentViewController.didPressPauseBarButton(sender)
@ -384,7 +384,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
assert(pendingViewControllers.count == 1)
pendingViewControllers.forEach { viewController in
guard let pendingPage = viewController as? MediaDetailViewController else {
owsFail("unexpected mediaDetailViewController: \(viewController)")
owsFailDebug("unexpected mediaDetailViewController: \(viewController)")
return
}
@ -399,7 +399,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
assert(previousViewControllers.count == 1)
previousViewControllers.forEach { viewController in
guard let previousPage = viewController as? MediaDetailViewController else {
owsFail("unexpected mediaDetailViewController: \(viewController)")
owsFailDebug("unexpected mediaDetailViewController: \(viewController)")
return
}
@ -419,12 +419,12 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
Logger.debug("")
guard let previousDetailViewController = viewController as? MediaDetailViewController else {
owsFail("unexpected viewController: \(viewController)")
owsFailDebug("unexpected viewController: \(viewController)")
return nil
}
guard let mediaGalleryDataSource = self.mediaGalleryDataSource else {
owsFail("mediaGalleryDataSource was unexpectedly nil")
owsFailDebug("mediaGalleryDataSource was unexpectedly nil")
return nil
}
@ -444,12 +444,12 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
Logger.debug("")
guard let previousDetailViewController = viewController as? MediaDetailViewController else {
owsFail("unexpected viewController: \(viewController)")
owsFailDebug("unexpected viewController: \(viewController)")
return nil
}
guard let mediaGalleryDataSource = self.mediaGalleryDataSource else {
owsFail("mediaGalleryDataSource was unexpectedly nil")
owsFailDebug("mediaGalleryDataSource was unexpectedly nil")
return nil
}
@ -486,7 +486,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
}
guard let viewItem = fetchedItem else {
owsFail("viewItem was unexpectedly nil")
owsFailDebug("viewItem was unexpectedly nil")
return nil
}
@ -504,7 +504,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
currentViewController.stopAnyVideo()
guard let mediaGalleryDataSource = self.mediaGalleryDataSource else {
owsFail("mediaGalleryDataSource was unexpectedly nil")
owsFailDebug("mediaGalleryDataSource was unexpectedly nil")
self.presentingViewController?.dismiss(animated: true)
return
@ -524,21 +524,21 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
public func mediaDetailViewController(_ mediaDetailViewController: MediaDetailViewController, requestDelete conversationViewItem: ConversationViewItem) {
guard let mediaGalleryDataSource = self.mediaGalleryDataSource else {
owsFail("mediaGalleryDataSource was unexpectedly nil")
owsFailDebug("mediaGalleryDataSource was unexpectedly nil")
self.presentingViewController?.dismiss(animated: true)
return
}
guard let message = conversationViewItem.interaction as? TSMessage else {
owsFail("unexpected interaction: \(type(of: conversationViewItem))")
owsFailDebug("unexpected interaction: \(type(of: conversationViewItem))")
self.presentingViewController?.dismiss(animated: true)
return
}
guard let galleryItem = self.mediaGalleryDataSource?.galleryItems.first(where: { $0.message == message }) else {
owsFail("unexpected interaction: \(type(of: conversationViewItem))")
owsFailDebug("unexpected interaction: \(type(of: conversationViewItem))")
self.presentingViewController?.dismiss(animated: true)
return
@ -572,7 +572,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
case is TSOutgoingMessage:
return NSLocalizedString("MEDIA_GALLERY_SENDER_NAME_YOU", comment: "Short sender label for media sent by you")
default:
owsFail("Unknown message type: \(type(of: message))")
owsFailDebug("Unknown message type: \(type(of: message))")
return ""
}
}
@ -609,7 +609,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
private func updateTitle() {
guard let currentItem = self.currentItem else {
owsFail("currentItem was unexpectedly nil")
owsFailDebug("currentItem was unexpectedly nil")
return
}
updateTitle(item: currentItem)

View File

@ -14,14 +14,14 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
private var galleryItems: [GalleryDate: [MediaGalleryItem]] {
guard let mediaGalleryDataSource = self.mediaGalleryDataSource else {
owsFail("mediaGalleryDataSource was unexpectedly nil")
owsFailDebug("mediaGalleryDataSource was unexpectedly nil")
return [:]
}
return mediaGalleryDataSource.sections
}
private var galleryDates: [GalleryDate] {
guard let mediaGalleryDataSource = self.mediaGalleryDataSource else {
owsFail("mediaGalleryDataSource was unexpectedly nil")
owsFailDebug("mediaGalleryDataSource was unexpectedly nil")
return []
}
return mediaGalleryDataSource.sectionDates
@ -76,7 +76,7 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
self.title = MediaStrings.allMedia
guard let collectionView = self.collectionView else {
owsFail("collectionView was unexpectedly nil")
owsFailDebug("collectionView was unexpectedly nil")
return
}
@ -131,7 +131,7 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
}
guard let indexPath = self.indexPath(galleryItem: focusedItem) else {
owsFail("unexpectedly unable to find indexPath for focusedItem: \(focusedItem)")
owsFailDebug("unexpectedly unable to find indexPath for focusedItem: \(focusedItem)")
return
}
@ -207,12 +207,12 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
Logger.debug("")
guard let galleryCell = self.collectionView(collectionView, cellForItemAt: indexPath) as? MediaGalleryCell else {
owsFail("galleryCell was unexpectedly nil")
owsFailDebug("galleryCell was unexpectedly nil")
return
}
guard let galleryItem = galleryCell.item else {
owsFail("galleryItem was unexpectedly nil")
owsFailDebug("galleryItem was unexpectedly nil")
return
}
@ -268,12 +268,12 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
}
guard let sectionDate = self.galleryDates[safe: sectionIdx - 1] else {
owsFail("unknown section: \(sectionIdx)")
owsFailDebug("unknown section: \(sectionIdx)")
return 0
}
guard let section = self.galleryItems[sectionDate] else {
owsFail("no section for date: \(sectionDate)")
owsFailDebug("no section for date: \(sectionDate)")
return 0
}
@ -287,7 +287,7 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
guard galleryDates.count > 0 else {
guard let sectionHeader = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: MediaGalleryStaticHeader.reuseIdentifier, for: indexPath) as? MediaGalleryStaticHeader else {
owsFail("unable to build section header for kLoadOlderSectionIdx")
owsFailDebug("unable to build section header for kLoadOlderSectionIdx")
return defaultView
}
let title = NSLocalizedString("GALLERY_TILES_EMPTY_GALLERY", comment: "Label indicating media gallery is empty")
@ -300,7 +300,7 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
case kLoadOlderSectionIdx:
guard let sectionHeader = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: MediaGalleryStaticHeader.reuseIdentifier, for: indexPath) as? MediaGalleryStaticHeader else {
owsFail("unable to build section header for kLoadOlderSectionIdx")
owsFailDebug("unable to build section header for kLoadOlderSectionIdx")
return defaultView
}
let title = NSLocalizedString("GALLERY_TILES_LOADING_OLDER_LABEL", comment: "Label indicating loading is in progress")
@ -309,7 +309,7 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
case loadNewerSectionIdx:
guard let sectionHeader = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: MediaGalleryStaticHeader.reuseIdentifier, for: indexPath) as? MediaGalleryStaticHeader else {
owsFail("unable to build section header for kLoadOlderSectionIdx")
owsFailDebug("unable to build section header for kLoadOlderSectionIdx")
return defaultView
}
let title = NSLocalizedString("GALLERY_TILES_LOADING_MORE_RECENT_LABEL", comment: "Label indicating loading is in progress")
@ -317,11 +317,11 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
return sectionHeader
default:
guard let sectionHeader = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: MediaGallerySectionHeader.reuseIdentifier, for: indexPath) as? MediaGallerySectionHeader else {
owsFail("unable to build section header for indexPath: \(indexPath)")
owsFailDebug("unable to build section header for indexPath: \(indexPath)")
return defaultView
}
guard let date = self.galleryDates[safe: indexPath.section - 1] else {
owsFail("unknown section for indexPath: \(indexPath)")
owsFailDebug("unknown section for indexPath: \(indexPath)")
return defaultView
}
@ -339,25 +339,25 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
let defaultCell = UICollectionViewCell()
guard galleryDates.count > 0 else {
owsFail("unexpected cell for loadNewerSectionIdx")
owsFailDebug("unexpected cell for loadNewerSectionIdx")
return defaultCell
}
switch indexPath.section {
case kLoadOlderSectionIdx:
owsFail("unexpected cell for kLoadOlderSectionIdx")
owsFailDebug("unexpected cell for kLoadOlderSectionIdx")
return defaultCell
case loadNewerSectionIdx:
owsFail("unexpected cell for loadNewerSectionIdx")
owsFailDebug("unexpected cell for loadNewerSectionIdx")
return defaultCell
default:
guard let galleryItem = galleryItem(at: indexPath) else {
owsFail("no message for path: \(indexPath)")
owsFailDebug("no message for path: \(indexPath)")
return defaultCell
}
guard let cell = self.collectionView?.dequeueReusableCell(withReuseIdentifier: MediaGalleryCell.reuseIdentifier, for: indexPath) as? MediaGalleryCell else {
owsFail("unexpected cell for indexPath: \(indexPath)")
owsFailDebug("unexpected cell for indexPath: \(indexPath)")
return defaultCell
}
@ -369,17 +369,17 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
func galleryItem(at indexPath: IndexPath) -> MediaGalleryItem? {
guard let sectionDate = self.galleryDates[safe: indexPath.section - 1] else {
owsFail("unknown section: \(indexPath.section)")
owsFailDebug("unknown section: \(indexPath.section)")
return nil
}
guard let sectionItems = self.galleryItems[sectionDate] else {
owsFail("no section for date: \(sectionDate)")
owsFailDebug("no section for date: \(sectionDate)")
return nil
}
guard let galleryItem = sectionItems[safe: indexPath.row] else {
owsFail("no message for row: \(indexPath.row)")
owsFailDebug("no message for row: \(indexPath.row)")
return nil
}
@ -400,7 +400,7 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
}
guard let mediaGalleryDataSource = self.mediaGalleryDataSource else {
owsFail("mediaGalleryDataSource was unexpectedly nil")
owsFailDebug("mediaGalleryDataSource was unexpectedly nil")
return CGSize.zero
}
@ -428,7 +428,7 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
func updateDeleteButton() {
guard let collectionView = self.collectionView else {
owsFail("collectionView was unexpectedly nil")
owsFailDebug("collectionView was unexpectedly nil")
return
}
@ -455,7 +455,7 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
isInBatchSelectMode = true
guard let collectionView = self.collectionView else {
owsFail("collectionView was unexpectedly nil")
owsFailDebug("collectionView was unexpectedly nil")
return
}
@ -487,7 +487,7 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
isInBatchSelectMode = false
guard let collectionView = self.collectionView else {
owsFail("collectionView was unexpectedly nil")
owsFailDebug("collectionView was unexpectedly nil")
return
}
@ -512,19 +512,19 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
Logger.debug("")
guard let collectionView = self.collectionView else {
owsFail("collectionView was unexpectedly nil")
owsFailDebug("collectionView was unexpectedly nil")
return
}
guard let indexPaths = collectionView.indexPathsForSelectedItems else {
owsFail("indexPaths was unexpectedly nil")
owsFailDebug("indexPaths was unexpectedly nil")
return
}
let items: [MediaGalleryItem] = indexPaths.compactMap { return self.galleryItem(at: $0) }
guard let mediaGalleryDataSource = self.mediaGalleryDataSource else {
owsFail("mediaGalleryDataSource was unexpectedly nil")
owsFailDebug("mediaGalleryDataSource was unexpectedly nil")
return
}
@ -560,7 +560,7 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
Logger.debug("")
guard let collectionView = self.collectionView else {
owsFail("collectionView was unexpectedly nil")
owsFailDebug("collectionView was unexpectedly nil")
return
}
@ -573,7 +573,7 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
Logger.debug("with deletedSections: \(deletedSections) deletedItems: \(deletedItems)")
guard let collectionView = self.collectionView else {
owsFail("collectionView was unexpetedly nil")
owsFailDebug("collectionView was unexpetedly nil")
return
}
@ -625,12 +625,12 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
}
guard let collectionView = self.collectionView else {
owsFail("collectionView was unexpectedly nil")
owsFailDebug("collectionView was unexpectedly nil")
return
}
guard let mediaGalleryDataSource = self.mediaGalleryDataSource else {
owsFail("mediaGalleryDataSource was unexpectedly nil")
owsFailDebug("mediaGalleryDataSource was unexpectedly nil")
return
}

View File

@ -97,13 +97,13 @@ class MenuActionsViewController: UIViewController, MenuActionSheetDelegate {
private func addSnapshotFocusedView() -> UIView? {
guard let snapshotView = self.focusedView.snapshotView(afterScreenUpdates: false) else {
owsFail("snapshotView was unexpectedly nil")
owsFailDebug("snapshotView was unexpectedly nil")
return nil
}
view.addSubview(snapshotView)
guard let focusedViewSuperview = focusedView.superview else {
owsFail("focusedViewSuperview was unexpectedly nil")
owsFailDebug("focusedViewSuperview was unexpectedly nil")
return nil
}
@ -115,18 +115,18 @@ class MenuActionsViewController: UIViewController, MenuActionSheetDelegate {
private func animatePresentation() {
guard let actionSheetViewVerticalConstraint = self.actionSheetViewVerticalConstraint else {
owsFail("actionSheetViewVerticalConstraint was unexpectedly nil")
owsFailDebug("actionSheetViewVerticalConstraint was unexpectedly nil")
return
}
guard let focusedViewSuperview = focusedView.superview else {
owsFail("focusedViewSuperview was unexpectedly nil")
owsFailDebug("focusedViewSuperview was unexpectedly nil")
return
}
// darken background
guard let snapshotView = addSnapshotFocusedView() else {
owsFail("snapshotView was unexpectedly nil")
owsFailDebug("snapshotView was unexpectedly nil")
return
}
@ -169,19 +169,19 @@ class MenuActionsViewController: UIViewController, MenuActionSheetDelegate {
private func animateDismiss(action: MenuAction?) {
guard let actionSheetViewVerticalConstraint = self.actionSheetViewVerticalConstraint else {
owsFail("actionSheetVerticalConstraint was unexpectedly nil")
owsFailDebug("actionSheetVerticalConstraint was unexpectedly nil")
self.delegate?.menuActionsDidHide(self)
return
}
guard let snapshotView = self.snapshotView else {
owsFail("snapshotView was unexpectedly nil")
owsFailDebug("snapshotView was unexpectedly nil")
self.delegate?.menuActionsDidHide(self)
return
}
guard let presentationFocusOffset = self.presentationFocusOffset else {
owsFail("presentationFocusOffset was unexpectedly nil")
owsFailDebug("presentationFocusOffset was unexpectedly nil")
self.delegate?.menuActionsDidHide(self)
return
}
@ -231,7 +231,7 @@ class MenuActionsViewController: UIViewController, MenuActionSheetDelegate {
didInformDelegateOfDismissalAnimation = true
guard let presentationFocusOffset = self.presentationFocusOffset else {
owsFail("presentationFocusOffset was unexpectedly nil")
owsFailDebug("presentationFocusOffset was unexpectedly nil")
self.delegate?.menuActionsDidHide(self)
return
}

View File

@ -181,7 +181,7 @@ class MessageDetailViewController: OWSViewController, MediaGalleryDataSourceDele
private func updateContent() {
guard let contentView = contentView else {
owsFail("Missing contentView")
owsFailDebug("Missing contentView")
return
}
@ -234,7 +234,7 @@ class MessageDetailViewController: OWSViewController, MediaGalleryDataSourceDele
for recipientId in messageRecipientIds {
guard let recipientState = outgoingMessage.recipientState(forRecipientId: recipientId) else {
owsFail("no message status for recipient: \(recipientId).")
owsFailDebug("no message status for recipient: \(recipientId).")
continue
}
@ -370,7 +370,7 @@ class MessageDetailViewController: OWSViewController, MediaGalleryDataSourceDele
if rows.isEmpty {
// Neither attachment nor body.
owsFail("Message has neither attachment nor body.")
owsFailDebug("Message has neither attachment nor body.")
rows.append(valueRow(name: NSLocalizedString("MESSAGE_METADATA_VIEW_NO_ATTACHMENT_OR_BODY",
comment: "Label for messages without a body or attachment in the 'message metadata' view."),
value: ""))
@ -627,7 +627,7 @@ class MessageDetailViewController: OWSViewController, MediaGalleryDataSourceDele
func didTapContactShare(_ viewItem: ConversationViewItem) {
guard let contactShare = viewItem.contactShare else {
owsFail("missing contact.")
owsFailDebug("missing contact.")
return
}
let contactViewController = ContactViewController(contactShare: contactShare)
@ -652,12 +652,12 @@ class MessageDetailViewController: OWSViewController, MediaGalleryDataSourceDele
AssertIsOnMainThread()
guard let mediaURL = attachmentStream.mediaURL() else {
owsFail("mediaURL was unexpectedly nil for attachment: \(attachmentStream)")
owsFailDebug("mediaURL was unexpectedly nil for attachment: \(attachmentStream)")
return
}
guard FileManager.default.fileExists(atPath: mediaURL.path) else {
owsFail("audio file missing at path: \(mediaURL)")
owsFailDebug("audio file missing at path: \(mediaURL)")
return
}
@ -682,7 +682,7 @@ class MessageDetailViewController: OWSViewController, MediaGalleryDataSourceDele
func didTapTruncatedTextMessage(_ conversationItem: ConversationViewItem) {
guard let navigationController = self.navigationController else {
owsFail("navigationController was unexpectedly nil")
owsFailDebug("navigationController was unexpectedly nil")
return
}
@ -721,7 +721,7 @@ class MessageDetailViewController: OWSViewController, MediaGalleryDataSourceDele
guard (items.map({ $0.message }) == [self.message]) else {
// Should only be one message we can delete when viewing message details
owsFail("Unexpectedly informed of irrelevant message deletion")
owsFailDebug("Unexpectedly informed of irrelevant message deletion")
return
}

View File

@ -127,7 +127,7 @@ public class MessageRecipientStatusUtils: NSObject {
return (.sent, NSLocalizedString("MESSAGE_STATUS_SENT",
comment: "status message for sent messages"))
default:
owsFail("Message has unexpected status: \(outgoingMessage.messageState).")
owsFailDebug("Message has unexpected status: \(outgoingMessage.messageState).")
return (.sent, NSLocalizedString("MESSAGE_STATUS_SENT",
comment: "status message for sent messages"))
}

View File

@ -65,12 +65,12 @@ struct AudioSource: Hashable {
}
guard let lhsPortDescription = lhs.portDescription else {
owsFail("only the built in speaker should lack a port description")
owsFailDebug("only the built in speaker should lack a port description")
return false
}
guard let rhsPortDescription = rhs.portDescription else {
owsFail("only the built in speaker should lack a port description")
owsFailDebug("only the built in speaker should lack a port description")
return false
}
@ -193,7 +193,7 @@ protocol CallAudioServiceDelegate: class {
do {
try self.avAudioSession.overrideOutputAudioPort( isEnabled ? .speaker : .none )
} catch {
owsFail("failed to set \(#function) = \(isEnabled) with error: \(error)")
owsFailDebug("failed to set \(#function) = \(isEnabled) with error: \(error)")
}
}
}
@ -260,7 +260,7 @@ protocol CallAudioServiceDelegate: class {
}
} catch {
owsFail("failed setting audio source with error: \(error) isSpeakerPhoneEnabled: \(call.isSpeakerphoneEnabled)")
owsFailDebug("failed setting audio source with error: \(error) isSpeakerPhoneEnabled: \(call.isSpeakerphoneEnabled)")
}
}
@ -397,7 +397,7 @@ protocol CallAudioServiceDelegate: class {
private func play(sound: OWSSound) {
guard let newPlayer = OWSSounds.audioPlayer(for: sound) else {
owsFail("unable to build player for sound: \(OWSSounds.displayName(for: sound))")
owsFailDebug("unable to build player for sound: \(OWSSounds.displayName(for: sound))")
return
}
Logger.info("playing sound: \(OWSSounds.displayName(for: sound))")
@ -461,7 +461,7 @@ protocol CallAudioServiceDelegate: class {
var availableInputs: [AudioSource] {
guard let availableInputs = avAudioSession.availableInputs else {
// I'm not sure why this would happen, but it may indicate an error.
owsFail("No available inputs or inputs not ready")
owsFailDebug("No available inputs or inputs not ready")
return [AudioSource.builtInSpeaker]
}
@ -538,7 +538,7 @@ protocol CallAudioServiceDelegate: class {
}
} catch {
let message = "failed to set category: \(category) mode: \(String(describing: mode)), options: \(options) with error: \(error)"
owsFail(message)
owsFailDebug(message)
}
if audioSessionChanged {

View File

@ -403,7 +403,7 @@ private class SignalCallData: NSObject {
throw CallError.obsoleteCall(description: "obsolete call")
}
guard let peerConnectionClient = self.peerConnectionClient else {
owsFail("Missing peerConnectionClient")
owsFailDebug("Missing peerConnectionClient")
throw CallError.obsoleteCall(description: "Missing peerConnectionClient")
}
@ -414,7 +414,7 @@ private class SignalCallData: NSObject {
let callMessage = OWSOutgoingCallMessage(thread: call.thread, offerMessage: try offerBuilder.build())
return self.messageSender.sendPromise(message: callMessage)
} catch {
owsFail("Couldn't build proto")
owsFailDebug("Couldn't build proto")
throw CallError.fatalError(description: "Couldn't build proto")
}
}
@ -552,7 +552,7 @@ private class SignalCallData: NSObject {
handleMissedCall(call)
} catch {
owsFail("Couldn't build proto")
owsFailDebug("Couldn't build proto")
}
}
@ -603,7 +603,7 @@ private class SignalCallData: NSObject {
switch untrustedIdentity!.verificationState {
case .verified:
owsFail("shouldn't have missed a call due to untrusted identity if the identity is verified")
owsFailDebug("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)
@ -721,7 +721,7 @@ private class SignalCallData: NSObject {
return self.messageSender.sendPromise(message: callAnswerMessage)
} catch {
owsFail("Couldn't build proto")
owsFailDebug("Couldn't build proto")
throw CallError.fatalError(description: "Couldn't build proto")
}
}.then {
@ -842,12 +842,12 @@ private class SignalCallData: NSObject {
}
guard let sdpMid = iceCandidate.sdpMid else {
owsFail("Missing sdpMid")
owsFailDebug("Missing sdpMid")
throw CallError.fatalError(description: "Missing sdpMid")
}
guard iceCandidate.sdpMLineIndex < UINT32_MAX else {
owsFail("Invalid sdpMLineIndex")
owsFailDebug("Invalid sdpMLineIndex")
throw CallError.fatalError(description: "Invalid sdpMLineIndex")
}
@ -867,7 +867,7 @@ private class SignalCallData: NSObject {
let sendPromise = self.messageSender.sendPromise(message: callMessage)
sendPromise.retainUntilComplete()
} catch {
owsFail("Couldn't build proto")
owsFailDebug("Couldn't build proto")
throw CallError.fatalError(description: "Couldn't build proto")
}
}.catch { error in
@ -908,7 +908,7 @@ private class SignalCallData: NSObject {
case .reconnecting:
call.state = .connected
case .idle, .localRinging, .localFailure, .localHangup, .remoteHangup, .remoteBusy:
owsFail("unexpected call state: \(call.state): \(call.identifiersForLogs).")
owsFailDebug("unexpected call state: \(call.state): \(call.identifiersForLogs).")
}
}
@ -931,7 +931,7 @@ private class SignalCallData: NSObject {
case .connected:
call.state = .reconnecting
default:
owsFail("unexpected call state: \(call.state): \(call.identifiersForLogs).")
owsFailDebug("unexpected call state: \(call.state): \(call.identifiersForLogs).")
}
}
@ -987,7 +987,7 @@ private class SignalCallData: NSObject {
guard let call = self.call else {
// This should never happen; return to a known good state.
owsFail("call was unexpectedly nil")
owsFailDebug("call was unexpectedly nil")
OWSProdError(OWSAnalyticsEvents.callServiceCallMissing(), file: #file, function: #function, line: #line)
handleFailedCurrentCall(error: CallError.assertionError(description: "\(self.logTag) call was unexpectedly nil"))
return
@ -995,7 +995,7 @@ private class SignalCallData: NSObject {
guard call.localId == localId else {
// This should never happen; return to a known good state.
owsFail("callLocalId:\(localId) doesn't match current calls: \(call.localId)")
owsFailDebug("callLocalId:\(localId) doesn't match current calls: \(call.localId)")
OWSProdError(OWSAnalyticsEvents.callServiceCallIdMismatch(), file: #file, function: #function, line: #line)
handleFailedCurrentCall(error: CallError.assertionError(description: "\(self.logTag) callLocalId:\(localId) doesn't match current calls: \(call.localId)"))
return
@ -1091,7 +1091,7 @@ private class SignalCallData: NSObject {
guard let call = self.call else {
// This should never happen; return to a known good state.
owsFail("call was unexpectedly nil")
owsFailDebug("call was unexpectedly nil")
OWSProdError(OWSAnalyticsEvents.callServiceCallMissing(), file: #file, function: #function, line: #line)
handleFailedCurrentCall(error: CallError.assertionError(description: "\(self.logTag) call was unexpectedly nil"))
return
@ -1099,7 +1099,7 @@ private class SignalCallData: NSObject {
guard call.localId == localId else {
// This should never happen; return to a known good state.
owsFail("callLocalId:\(localId) doesn't match current calls: \(call.localId)")
owsFailDebug("callLocalId:\(localId) doesn't match current calls: \(call.localId)")
OWSProdError(OWSAnalyticsEvents.callServiceCallIdMismatch(), file: #file, function: #function, line: #line)
handleFailedCurrentCall(error: CallError.assertionError(description: "\(self.logTag) callLocalId:\(localId) doesn't match current calls: \(call.localId)"))
return
@ -1119,7 +1119,7 @@ private class SignalCallData: NSObject {
Logger.info("\(call.identifiersForLogs).")
if let callRecord = call.callRecord {
owsFail("Not expecting callrecord to already be set")
owsFailDebug("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)
@ -1162,7 +1162,7 @@ private class SignalCallData: NSObject {
callRecord.updateCallType(RPRecentCallTypeOutgoingMissed)
}
} else {
owsFail("missing call record")
owsFailDebug("missing call record")
}
// TODO something like this lifted from Signal-Android.
@ -1281,7 +1281,7 @@ private class SignalCallData: NSObject {
AssertIsOnMainThread()
guard let frontmostViewController = UIApplication.shared.frontmostViewController else {
owsFail("could not identify frontmostViewController")
owsFailDebug("could not identify frontmostViewController")
return
}
@ -1359,7 +1359,7 @@ private class SignalCallData: NSObject {
guard let callData = self.callData else {
// This should never happen; return to a known good state.
owsFail("received data message, but there is no current call. Ignoring.")
owsFailDebug("received data message, but there is no current call. Ignoring.")
OWSProdError(OWSAnalyticsEvents.callServiceCallMissing(), file: #file, function: #function, line: #line)
handleFailedCurrentCall(error: CallError.assertionError(description: "\(self.logTag) received data message, but there is no current call. Ignoring."))
return
@ -1371,7 +1371,7 @@ private class SignalCallData: NSObject {
guard connected.id == call.signalingId else {
// This should never happen; return to a known good state.
owsFail("received connected message for call with id:\(connected.id) but current call has id:\(call.signalingId)")
owsFailDebug("received connected message for call with id:\(connected.id) but current call has id:\(call.signalingId)")
OWSProdError(OWSAnalyticsEvents.callServiceCallIdMismatch(), file: #file, function: #function, line: #line)
handleFailedCurrentCall(error: CallError.assertionError(description: "\(self.logTag) received connected message for call with id:\(connected.id) but current call has id:\(call.signalingId)"))
return
@ -1385,7 +1385,7 @@ private class SignalCallData: NSObject {
guard hangup.id == call.signalingId else {
// This should never happen; return to a known good state.
owsFail("received hangup message for call with id:\(hangup.id) but current call has id:\(call.signalingId)")
owsFailDebug("received hangup message for call with id:\(hangup.id) but current call has id:\(call.signalingId)")
OWSProdError(OWSAnalyticsEvents.callServiceCallIdMismatch(), file: #file, function: #function, line: #line)
handleFailedCurrentCall(error: CallError.assertionError(description: "\(self.logTag) received hangup message for call with id:\(hangup.id) but current call has id:\(call.signalingId)"))
return
@ -1558,7 +1558,7 @@ private class SignalCallData: NSObject {
AssertIsOnMainThread()
if case CallError.assertionError(description: let description) = error {
owsFail(description)
owsFailDebug(description)
}
if let failedCall = failedCall {
@ -1748,7 +1748,7 @@ private class SignalCallData: NSObject {
}
guard let call = strongSelf.call else {
owsFail("call has since ended. Timer should have been invalidated.")
owsFailDebug("call has since ended. Timer should have been invalidated.")
timer.invalidate()
return
}
@ -1759,11 +1759,11 @@ private class SignalCallData: NSObject {
func ensureCallScreenPresented(call: SignalCall) {
guard let currentCall = self.call else {
owsFail("obsolete call: \(call.identifiersForLogs)")
owsFailDebug("obsolete call: \(call.identifiersForLogs)")
return
}
guard currentCall == call else {
owsFail("obsolete call: \(call.identifiersForLogs)")
owsFailDebug("obsolete call: \(call.identifiersForLogs)")
return
}
@ -1789,7 +1789,7 @@ private class SignalCallData: NSObject {
if !OWSWindowManager.shared().hasCall() {
OWSProdError(OWSAnalyticsEvents.callServiceCallViewCouldNotPresent(), file: #file, function: #function, line: #line)
owsFail("Call terminated due to missing call view.")
owsFailDebug("Call terminated due to missing call view.")
self.handleFailedCall(failedCall: call, error: CallError.assertionError(description: "Call view didn't present after \(kMaxViewPresentationDelay) seconds"))
return
}

View File

@ -68,12 +68,12 @@ class NonCallKitCallUIAdaptee: NSObject, CallUIAdaptee {
AssertIsOnMainThread()
guard let call = self.callService.call else {
owsFail("No current call.")
owsFailDebug("No current call.")
return
}
guard call.localId == localId else {
owsFail("localId does not match current call")
owsFailDebug("localId does not match current call")
return
}
@ -84,7 +84,7 @@ class NonCallKitCallUIAdaptee: NSObject, CallUIAdaptee {
AssertIsOnMainThread()
guard call.localId == self.callService.call?.localId else {
owsFail("localId does not match current call")
owsFailDebug("localId does not match current call")
return
}
@ -96,12 +96,12 @@ class NonCallKitCallUIAdaptee: NSObject, CallUIAdaptee {
AssertIsOnMainThread()
guard let call = self.callService.call else {
owsFail("No current call.")
owsFailDebug("No current call.")
return
}
guard call.localId == localId else {
owsFail("localId does not match current call")
owsFailDebug("localId does not match current call")
return
}
@ -112,7 +112,7 @@ class NonCallKitCallUIAdaptee: NSObject, CallUIAdaptee {
AssertIsOnMainThread()
guard call.localId == self.callService.call?.localId else {
owsFail("localId does not match current call")
owsFailDebug("localId does not match current call")
return
}
@ -131,7 +131,7 @@ class NonCallKitCallUIAdaptee: NSObject, 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 {
owsFail("localId does not match current call")
owsFailDebug("localId does not match current call")
return
}
@ -160,7 +160,7 @@ class NonCallKitCallUIAdaptee: NSObject, CallUIAdaptee {
AssertIsOnMainThread()
guard call.localId == self.callService.call?.localId else {
owsFail("localId does not match current call")
owsFailDebug("localId does not match current call")
return
}
@ -171,7 +171,7 @@ class NonCallKitCallUIAdaptee: NSObject, CallUIAdaptee {
AssertIsOnMainThread()
guard call.localId == self.callService.call?.localId else {
owsFail("localId does not match current call")
owsFailDebug("localId does not match current call")
return
}

View File

@ -46,7 +46,7 @@ import SignalMessaging
// because it can change after app launch due to user settings
let callUIAdapter = SignalApp.shared().callUIAdapter
guard let frontmostViewController = UIApplication.shared.frontmostViewController else {
owsFail("could not identify frontmostViewController")
owsFailDebug("could not identify frontmostViewController")
return false
}

View File

@ -311,7 +311,7 @@ class PeerConnectionClient: NSObject, RTCPeerConnectionDelegate, RTCDataChannelD
configuration: configuration) else {
// TODO fail outgoing call?
owsFail("dataChannel was unexpectedly nil")
owsFailDebug("dataChannel was unexpectedly nil")
return
}
dataChannel.delegate = proxy
@ -362,7 +362,7 @@ class PeerConnectionClient: NSObject, RTCPeerConnectionDelegate, RTCDataChannelD
guard let strongSelf = proxyCopy.get() else { return }
guard let captureController = strongSelf.videoCaptureController else {
owsFail("captureController was unexpectedly nil")
owsFailDebug("captureController was unexpectedly nil")
return
}
@ -383,7 +383,7 @@ class PeerConnectionClient: NSObject, RTCPeerConnectionDelegate, RTCDataChannelD
}
guard let captureController = strongSelf.videoCaptureController else {
owsFail("videoCaptureController was unexpectedly nil")
owsFailDebug("videoCaptureController was unexpectedly nil")
return nil
}
@ -889,11 +889,11 @@ class PeerConnectionClient: NSObject, RTCPeerConnectionDelegate, RTCDataChannelD
return
}
guard peerConnection == peerConnectionParam else {
owsFail("mismatched peerConnection callback.")
owsFailDebug("mismatched peerConnection callback.")
return
}
guard stream.videoTracks.count > 0 else {
owsFail("didAdd stream missing stream.")
owsFailDebug("didAdd stream missing stream.")
return
}
let remoteVideoTrack = stream.videoTracks[0]
@ -946,7 +946,7 @@ class PeerConnectionClient: NSObject, RTCPeerConnectionDelegate, RTCDataChannelD
return
}
guard peerConnection == peerConnectionParam else {
owsFail("mismatched peerConnection callback.")
owsFailDebug("mismatched peerConnection callback.")
return
}
@ -988,7 +988,7 @@ class PeerConnectionClient: NSObject, RTCPeerConnectionDelegate, RTCDataChannelD
return
}
guard peerConnection == peerConnectionParam else {
owsFail("mismatched peerConnection callback.")
owsFailDebug("mismatched peerConnection callback.")
return
}
Logger.info("adding local ICE candidate:\(candidate.sdp)")
@ -1021,12 +1021,12 @@ class PeerConnectionClient: NSObject, RTCPeerConnectionDelegate, RTCDataChannelD
return
}
guard peerConnection == peerConnectionParam else {
owsFail("mismatched peerConnection callback.")
owsFailDebug("mismatched peerConnection callback.")
return
}
Logger.info("didOpen dataChannel:\(dataChannel)")
if strongSelf.dataChannel != nil {
owsFail("dataChannel unexpectedly set twice.")
owsFailDebug("dataChannel unexpectedly set twice.")
}
strongSelf.dataChannel = dataChannel
dataChannel.delegate = strongSelf.proxy
@ -1174,12 +1174,12 @@ class VideoCaptureController {
let position: AVCaptureDevice.Position = isUsingFrontCamera ? .front : .back
guard let device: AVCaptureDevice = self.device(position: position) else {
owsFail("unable to find captureDevice")
owsFailDebug("unable to find captureDevice")
return
}
guard let format: AVCaptureDevice.Format = self.format(device: device) else {
owsFail("unable to find captureDevice")
owsFailDebug("unable to find captureDevice")
return
}

View File

@ -172,7 +172,7 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
AssertIsOnMainThread()
Logger.info("")
owsFail("CallKit should answer calls via system call screen, not via notifications.")
owsFailDebug("CallKit should answer calls via system call screen, not via notifications.")
}
func answerCall(_ call: SignalCall) {
@ -185,7 +185,7 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
func declineCall(localId: UUID) {
AssertIsOnMainThread()
owsFail("CallKit should decline calls via system call screen, not via notifications.")
owsFailDebug("CallKit should decline calls via system call screen, not via notifications.")
}
func declineCall(_ call: SignalCall) {
@ -370,7 +370,7 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
func provider(_ provider: CXProvider, timedOutPerforming action: CXAction) {
AssertIsOnMainThread()
owsFail("Timed out while performing \(action)")
owsFailDebug("Timed out while performing \(action)")
// React to the action timeout if necessary, such as showing an error UI.
}

View File

@ -43,7 +43,7 @@ extension CallUIAdaptee {
OWSWindowManager.shared().startCall(callViewController)
} else {
guard let presentingViewController = UIApplication.shared.frontmostViewControllerIgnoringAlerts else {
owsFail("view controller unexpectedly nil")
owsFailDebug("view controller unexpectedly nil")
return
}
@ -67,7 +67,7 @@ extension CallUIAdaptee {
AssertIsOnMainThread()
guard self.callService.call == nil else {
owsFail("unexpectedly found an existing call when trying to start outgoing call: \(recipientId)")
owsFailDebug("unexpectedly found an existing call when trying to start outgoing call: \(recipientId)")
return
}

View File

@ -58,7 +58,7 @@ import SignalMessaging
return super.storageBehaviorForProperty(withKey: propertyKey)
} else {
// Being conservative here in case we rename a property.
owsFail("unknown property \(propertyKey)")
owsFailDebug("unknown property \(propertyKey)")
return super.storageBehaviorForProperty(withKey: propertyKey)
}
}

View File

@ -72,7 +72,7 @@ public enum PushRegistrationError: Error {
@objc
public func didRegisterUserNotificationSettings() {
guard let fulfillUserNotificationSettingsPromise = self.fulfillUserNotificationSettingsPromise else {
owsFail("promise completion in \(#function) unexpectedly nil")
owsFailDebug("promise completion in \(#function) unexpectedly nil")
return
}
@ -85,7 +85,7 @@ public enum PushRegistrationError: Error {
@objc
public func didReceiveVanillaPushToken(_ tokenData: Data) {
guard let fulfillVanillaTokenPromise = self.fulfillVanillaTokenPromise else {
owsFail("promise completion in \(#function) unexpectedly nil")
owsFailDebug("promise completion in \(#function) unexpectedly nil")
return
}
@ -96,7 +96,7 @@ public enum PushRegistrationError: Error {
@objc
public func didFailToReceiveVanillaPushToken(error: Error) {
guard let rejectVanillaTokenPromise = self.rejectVanillaTokenPromise else {
owsFail("promise completion in \(#function) unexpectedly nil")
owsFailDebug("promise completion in \(#function) unexpectedly nil")
return
}
@ -116,7 +116,7 @@ public enum PushRegistrationError: Error {
assert(type == .voIP)
assert(credentials.type == .voIP)
guard let fulfillVoipTokenPromise = self.fulfillVoipTokenPromise else {
owsFail("fulfillVoipTokenPromise was unexpectedly nil")
owsFailDebug("fulfillVoipTokenPromise was unexpectedly nil")
return
}
@ -126,7 +126,7 @@ public enum PushRegistrationError: Error {
public func pushRegistry(_ registry: PKPushRegistry, didInvalidatePushTokenFor type: PKPushType) {
// It's not clear when this would happen. We've never previously handled it, but we should at
// least start learning if it happens.
owsFail("Invalid state")
owsFailDebug("Invalid state")
}
// MARK: helpers
@ -222,7 +222,7 @@ public enum PushRegistrationError: Error {
}.then { (pushTokenData: Data) -> String in
if self.isSusceptibleToFailedPushRegistration {
// Sentinal in case this bug is fixed.
owsFail("Device was unexpectedly able to complete push registration even though it was susceptible to failure.")
owsFailDebug("Device was unexpectedly able to complete push registration even though it was susceptible to failure.")
}
Logger.info("successfully registered for vanilla push notifications")
@ -257,7 +257,7 @@ public enum PushRegistrationError: Error {
}
guard let voipRegistry = self.voipRegistry else {
owsFail("failed to initialize voipRegistry")
owsFailDebug("failed to initialize voipRegistry")
reject(PushRegistrationError.assertionError(description: "\(self.logTag) failed to initialize voipRegistry"))
return promise.then { _ in
// coerce expected type of returned promise - we don't really care about the value,

View File

@ -60,7 +60,7 @@ class GiphyAssetSegment: NSObject {
public func append(data: Data) {
guard state == .downloading else {
owsFail("appending data in invalid state: \(state)")
owsFailDebug("appending data in invalid state: \(state)")
return
}
@ -69,11 +69,11 @@ class GiphyAssetSegment: NSObject {
public func mergeData(assetData: inout Data) -> Bool {
guard state == .complete else {
owsFail("merging data in invalid state: \(state)")
owsFailDebug("merging data in invalid state: \(state)")
return false
}
guard UInt(segmentData.count) == segmentLength else {
owsFail("segment data length: \(segmentData.count) doesn't match expected length: \(segmentLength)")
owsFailDebug("segment data length: \(segmentData.count) doesn't match expected length: \(segmentLength)")
return false
}
@ -152,7 +152,7 @@ enum GiphyAssetRequestState: UInt {
let contentLength = UInt(self.contentLength)
guard contentLength > 0 else {
owsFail("rendition missing contentLength")
owsFailDebug("rendition missing contentLength")
requestDidFail()
return 0
}
@ -206,7 +206,7 @@ enum GiphyAssetRequestState: UInt {
for segment in segments {
guard segment.state != .failed else {
owsFail("unexpected failed segment.")
owsFailDebug("unexpected failed segment.")
continue
}
if segment.state == state {
@ -228,7 +228,7 @@ enum GiphyAssetRequestState: UInt {
var result: UInt = 0
for segment in segments {
guard segment.state != .failed else {
owsFail("unexpected failed segment.")
owsFailDebug("unexpected failed segment.")
continue
}
if segment.state == .downloading {
@ -254,26 +254,26 @@ enum GiphyAssetRequestState: UInt {
var assetData = Data()
for segment in segments {
guard segment.state == .complete else {
owsFail("unexpected incomplete segment.")
owsFailDebug("unexpected incomplete segment.")
return nil
}
guard segment.totalDataSize() > 0 else {
owsFail("could not merge empty segment.")
owsFailDebug("could not merge empty segment.")
return nil
}
guard segment.mergeData(assetData: &assetData) else {
owsFail("failed to merge segment data.")
owsFailDebug("failed to merge segment data.")
return nil
}
}
guard assetData.count == contentLength else {
owsFail("asset data has unexpected length.")
owsFailDebug("asset data has unexpected length.")
return nil
}
guard assetData.count > 0 else {
owsFail("could not write empty asset to disk.")
owsFailDebug("could not write empty asset to disk.")
return nil
}
@ -288,7 +288,7 @@ enum GiphyAssetRequestState: UInt {
let asset = GiphyAsset(rendition: rendition, filePath: filePath)
return asset
} catch let error as NSError {
owsFail("file write failed: \(filePath), \(error)")
owsFailDebug("file write failed: \(filePath), \(error)")
return nil
}
}
@ -358,7 +358,7 @@ enum GiphyAssetRequestState: UInt {
let fileManager = FileManager.default
try fileManager.removeItem(atPath: filePathCopy)
} catch let error as NSError {
owsFail("file cleanup failed: \(filePathCopy), \(error)")
owsFailDebug("file cleanup failed: \(filePathCopy), \(error)")
}
}
}
@ -592,7 +592,7 @@ extension URLSessionTask {
let task = giphyDownloadSession.dataTask(with: request, completionHandler: { data, response, error -> Void in
if let data = data, data.count > 0 {
owsFail("HEAD request has unexpected body: \(data.count).")
owsFailDebug("HEAD request has unexpected body: \(data.count).")
}
self.handleAssetSizeResponse(assetRequest: assetRequest, response: response, error: error)
})
@ -602,7 +602,7 @@ extension URLSessionTask {
// Start a download task.
guard let assetSegment = assetRequest.firstWaitingSegment() else {
owsFail("queued asset request does not have a waiting segment.")
owsFailDebug("queued asset request does not have a waiting segment.")
return
}
assetSegment.state = .downloading
@ -629,25 +629,25 @@ extension URLSessionTask {
return
}
guard let httpResponse = response as? HTTPURLResponse else {
owsFail("Asset size response is invalid.")
owsFailDebug("Asset size response is invalid.")
assetRequest.state = .failed
self.assetRequestDidFail(assetRequest: assetRequest)
return
}
guard let contentLengthString = httpResponse.allHeaderFields["Content-Length"] as? String else {
owsFail("Asset size response is missing content length.")
owsFailDebug("Asset size response is missing content length.")
assetRequest.state = .failed
self.assetRequestDidFail(assetRequest: assetRequest)
return
}
guard let contentLength = Int(contentLengthString) else {
owsFail("Asset size response has unparsable content length.")
owsFailDebug("Asset size response has unparsable content length.")
assetRequest.state = .failed
self.assetRequestDidFail(assetRequest: assetRequest)
return
}
guard contentLength > 0 else {
owsFail("Asset size response has invalid content length.")
owsFailDebug("Asset size response has invalid content length.")
assetRequest.state = .failed
self.assetRequestDidFail(assetRequest: assetRequest)
return
@ -801,7 +801,7 @@ extension URLSessionTask {
// Don't back up Giphy downloads.
OWSFileSystem.protectFileOrFolder(atPath: dirPath)
} catch let error as NSError {
owsFail("ensureTempFolder failed: \(dirPath), \(error)")
owsFailDebug("ensureTempFolder failed: \(dirPath), \(error)")
gifFolderPath = tempDirPath
}
}

View File

@ -21,17 +21,17 @@ class AppUpdateNag: NSObject {
public func showAppUpgradeNagIfNecessary() {
guard let currentVersion = self.currentVersion else {
owsFail("currentVersion was unexpectedly nil")
owsFailDebug("currentVersion was unexpectedly nil")
return
}
guard let bundleIdentifier = self.bundleIdentifier else {
owsFail("bundleIdentifier was unexpectedly nil")
owsFailDebug("bundleIdentifier was unexpectedly nil")
return
}
guard let lookupURL = lookupURL(bundleIdentifier: bundleIdentifier) else {
owsFail("appStoreURL was unexpectedly nil")
owsFailDebug("appStoreURL was unexpectedly nil")
return
}
@ -110,7 +110,7 @@ class AppUpdateNag: NSObject {
// Only show nag if we are "at rest" in the home view or registration view without any
// alerts or dialogs showing.
guard let frontmostViewController = UIApplication.shared.frontmostViewController else {
owsFail("frontmostViewController was unexpectedly nil")
owsFailDebug("frontmostViewController was unexpectedly nil")
return
}

View File

@ -160,7 +160,7 @@ import CloudKit
failure: failure)
}
case .unknownItem:
owsFail("unexpected CloudKit response.")
owsFailDebug("unexpected CloudKit response.")
failure(invalidServiceResponseError())
}
}
@ -282,7 +282,7 @@ import CloudKit
failure: failure)
}
case .unknownItem:
owsFail("unexpected CloudKit response.")
owsFailDebug("unexpected CloudKit response.")
failure(invalidServiceResponseError())
}
}
@ -308,7 +308,7 @@ import CloudKit
switch outcome {
case .success:
guard let record = record else {
owsFail("missing fetching record.")
owsFailDebug("missing fetching record.")
failure(invalidServiceResponseError())
return
}
@ -424,7 +424,7 @@ import CloudKit
failure: failure)
}
case .unknownItem:
owsFail("unexpected CloudKit response.")
owsFailDebug("unexpected CloudKit response.")
failure(invalidServiceResponseError())
}
}

View File

@ -56,15 +56,15 @@ class AttachmentPointerView: UIStackView {
@objc internal func attachmentDownloadProgress(_ notification: Notification) {
guard let attachmentId = attachmentPointer.uniqueId else {
owsFail("Missing attachment id.")
owsFailDebug("Missing attachment id.")
return
}
guard let progress = (notification as NSNotification).userInfo?[kAttachmentDownloadProgressKey] as? NSNumber else {
owsFail("Attachment download notification missing progress.")
owsFailDebug("Attachment download notification missing progress.")
return
}
guard let notificationAttachmentId = (notification as NSNotification).userInfo?[kAttachmentDownloadAttachmentIDKey] as? String else {
owsFail("Attachment download notification missing attachment id.")
owsFailDebug("Attachment download notification missing attachment id.")
return
}
guard notificationAttachmentId == attachmentId else {

View File

@ -81,7 +81,7 @@ class QuotedReplyPreview: UIView {
func updateHeight() {
guard let quotedMessageView = quotedMessageView else {
owsFail("missing quotedMessageView")
owsFailDebug("missing quotedMessageView")
return
}
let size = quotedMessageView.size(forMaxWidth: CGFloat.infinity)

View File

@ -94,7 +94,7 @@ class ReminderView: UIView {
// Icon
let iconName = (CurrentAppContext().isRTL ? "system_disclosure_indicator_rtl" : "system_disclosure_indicator")
guard let iconImage = UIImage(named: iconName) else {
owsFail("missing icon.")
owsFailDebug("missing icon.")
return
}
let iconView = UIImageView(image: iconImage.withRenderingMode(.alwaysTemplate))

View File

@ -67,7 +67,7 @@ class FakeContactsManager: NSObject, ContactsManagerProtocol {
}
func compare(signalAccount left: SignalAccount, with right: SignalAccount) -> ComparisonResult {
owsFail("if this method ends up being used by the tests, we should provide a better implementation.")
owsFailDebug("if this method ends up being used by the tests, we should provide a better implementation.")
return .orderedAscending
}
@ -343,19 +343,19 @@ class ConversationSearcherTest: XCTestCase {
self.dbConnection.read { transaction in
for messageResult in messageResults {
guard let messageId = messageResult.messageId else {
owsFail("message result missing message id")
owsFailDebug("message result missing message id")
continue
}
guard let interaction = TSInteraction.fetch(uniqueId: messageId, transaction: transaction) else {
owsFail("couldn't load interaction for message result")
owsFailDebug("couldn't load interaction for message result")
continue
}
guard let message = interaction as? TSMessage else {
owsFail("invalid message for message result")
owsFailDebug("invalid message for message result")
continue
}
guard let messageBody = message.body else {
owsFail("message result missing message body")
owsFailDebug("message result missing message body")
continue
}
result.append(messageBody)
@ -365,7 +365,7 @@ class ConversationSearcherTest: XCTestCase {
return result.sorted()
}
// Mark: Helpers
// MARK: Helpers
private func searchConversations(searchText: String) -> [ThreadViewModel] {
let results = getResultSet(searchText: searchText)

View File

@ -67,7 +67,7 @@ public class AttachmentApprovalViewController: OWSViewController, CaptioningTool
let navController = OWSNavigationController(rootViewController: vc)
guard let navigationBar = navController.navigationBar as? OWSNavigationBar else {
owsFail("navigationBar was nil or unexpected class")
owsFailDebug("navigationBar was nil or unexpected class")
return navController
}
navigationBar.makeClear()
@ -170,7 +170,7 @@ public class AttachmentApprovalViewController: OWSViewController, CaptioningTool
if attachment.isVideo {
guard let videoURL = attachment.dataUrl else {
owsFail("Missing videoURL")
owsFailDebug("Missing videoURL")
return
}
@ -274,12 +274,12 @@ public class AttachmentApprovalViewController: OWSViewController, CaptioningTool
Logger.info("")
guard let videoPlayer = self.videoPlayer else {
owsFail("video player was unexpectedly nil")
owsFailDebug("video player was unexpectedly nil")
return
}
guard let playVideoButton = self.playVideoButton else {
owsFail("playVideoButton was unexpectedly nil")
owsFailDebug("playVideoButton was unexpectedly nil")
return
}
UIView.animate(withDuration: 0.1) {
@ -290,13 +290,13 @@ public class AttachmentApprovalViewController: OWSViewController, CaptioningTool
private func pauseVideo() {
guard let videoPlayer = self.videoPlayer else {
owsFail("video player was unexpectedly nil")
owsFailDebug("video player was unexpectedly nil")
return
}
videoPlayer.pause()
guard let playVideoButton = self.playVideoButton else {
owsFail("playVideoButton was unexpectedly nil")
owsFailDebug("playVideoButton was unexpectedly nil")
return
}
UIView.animate(withDuration: 0.1) {
@ -307,7 +307,7 @@ public class AttachmentApprovalViewController: OWSViewController, CaptioningTool
@objc
public func videoPlayerDidPlayToCompletion(_ videoPlayer: OWSVideoPlayer) {
guard let playVideoButton = self.playVideoButton else {
owsFail("playVideoButton was unexpectedly nil")
owsFailDebug("playVideoButton was unexpectedly nil")
return
}
@ -318,7 +318,7 @@ public class AttachmentApprovalViewController: OWSViewController, CaptioningTool
public func playerProgressBarDidStartScrubbing(_ playerProgressBar: PlayerProgressBar) {
guard let videoPlayer = self.videoPlayer else {
owsFail("video player was unexpectedly nil")
owsFailDebug("video player was unexpectedly nil")
return
}
videoPlayer.pause()
@ -326,7 +326,7 @@ public class AttachmentApprovalViewController: OWSViewController, CaptioningTool
public func playerProgressBar(_ playerProgressBar: PlayerProgressBar, scrubbedToTime time: CMTime) {
guard let videoPlayer = self.videoPlayer else {
owsFail("video player was unexpectedly nil")
owsFailDebug("video player was unexpectedly nil")
return
}
@ -335,7 +335,7 @@ public class AttachmentApprovalViewController: OWSViewController, CaptioningTool
public func playerProgressBar(_ playerProgressBar: PlayerProgressBar, didFinishScrubbingAtTime time: CMTime, shouldResumePlayback: Bool) {
guard let videoPlayer = self.videoPlayer else {
owsFail("video player was unexpectedly nil")
owsFailDebug("video player was unexpectedly nil")
return
}

View File

@ -26,7 +26,7 @@ public class ContactFieldView: UIView {
let addSpacerRow = {
guard let prevRow = lastRow else {
owsFail("missing last row")
owsFailDebug("missing last row")
return
}
let row = UIView()

View File

@ -264,7 +264,7 @@ public class ContactShareApprovalViewController: OWSViewController, EditContactS
delegate: self)
fieldViews.append(fieldView)
} else {
owsFail("could not load avatar image.")
owsFailDebug("could not load avatar image.")
}
}
@ -354,7 +354,7 @@ public class ContactShareApprovalViewController: OWSViewController, EditContactS
AssertIsOnMainThread()
guard let rootView = self.view else {
owsFail("missing root view.")
owsFailDebug("missing root view.")
return
}
@ -464,7 +464,7 @@ public class ContactShareApprovalViewController: OWSViewController, EditContactS
Logger.info("")
guard let delegate = self.delegate else {
owsFail("missing delegate.")
owsFailDebug("missing delegate.")
return
}
@ -479,7 +479,7 @@ public class ContactShareApprovalViewController: OWSViewController, EditContactS
Logger.info("")
guard let delegate = self.delegate else {
owsFail("missing delegate.")
owsFailDebug("missing delegate.")
return
}

View File

@ -92,7 +92,7 @@ class ContactNameFieldView: UIView {
hasUnsavedChanges = true
guard let delegate = self.delegate else {
owsFail("missing delegate.")
owsFailDebug("missing delegate.")
return
}
@ -244,7 +244,7 @@ public class EditContactShareNameViewController: OWSViewController, ContactNameF
AssertIsOnMainThread()
guard let rootView = self.view else {
owsFail("missing root view.")
owsFailDebug("missing root view.")
return
}
@ -289,7 +289,7 @@ public class EditContactShareNameViewController: OWSViewController, ContactNameF
Logger.info("")
guard let newName = OWSContactName() else {
owsFail("could not create a new name.")
owsFailDebug("could not create a new name.")
return
}
newName.namePrefix = namePrefixView.value().ows_stripped()
@ -302,14 +302,14 @@ public class EditContactShareNameViewController: OWSViewController, ContactNameF
let modifiedContactShare = contactShare.copy(withName: newName)
guard let delegate = self.delegate else {
owsFail("missing delegate.")
owsFailDebug("missing delegate.")
return
}
delegate.editContactShareNameView(self, didEditContactShare: modifiedContactShare)
guard let navigationController = self.navigationController else {
owsFail("Missing navigationController.")
owsFailDebug("Missing navigationController.")
return
}
navigationController.popViewController(animated: true)
@ -319,7 +319,7 @@ public class EditContactShareNameViewController: OWSViewController, ContactNameF
Logger.info("")
guard let navigationController = self.navigationController else {
owsFail("Missing navigationController.")
owsFailDebug("Missing navigationController.")
return
}
navigationController.popViewController(animated: true)

View File

@ -159,7 +159,7 @@ public class MessageApprovalViewController: OWSViewController, UITextViewDelegat
return recipientRow
}
guard let contactThread = self.thread as? TSContactThread else {
owsFail("Unexpected thread type")
owsFailDebug("Unexpected thread type")
return recipientRow
}

View File

@ -70,7 +70,7 @@ public class ConversationAvatarImageView: AvatarImageView {
self.recipientId = nil
self.groupThreadId = groupThread.uniqueId
default:
owsFail("unexpected thread type: \(thread)")
owsFailDebug("unexpected thread type: \(thread)")
self.recipientId = nil
self.groupThreadId = nil
}
@ -108,13 +108,13 @@ public class ConversationAvatarImageView: AvatarImageView {
Logger.debug("")
guard let changedRecipientId = notification.userInfo?[kNSNotificationKey_ProfileRecipientId] as? String else {
owsFail("recipientId was unexpectedly nil")
owsFailDebug("recipientId was unexpectedly nil")
return
}
guard let recipientId = self.recipientId else {
// shouldn't call this for group threads
owsFail("contactId was unexpectedly nil")
owsFailDebug("contactId was unexpectedly nil")
return
}
@ -130,13 +130,13 @@ public class ConversationAvatarImageView: AvatarImageView {
Logger.debug("")
guard let changedGroupThreadId = notification.userInfo?[TSGroupThread_NotificationKey_UniqueId] as? String else {
owsFail("groupThreadId was unexpectedly nil")
owsFailDebug("groupThreadId was unexpectedly nil")
return
}
guard let groupThreadId = self.groupThreadId else {
// shouldn't call this for contact threads
owsFail("groupThreadId was unexpectedly nil")
owsFailDebug("groupThreadId was unexpectedly nil")
return
}

View File

@ -24,7 +24,7 @@ import Foundation
@objc
public class func showAlert(_ alert: UIAlertController) {
guard let frontmostViewController = CurrentAppContext().frontmostViewController() else {
owsFail("frontmostViewController was unexpectedly nil")
owsFailDebug("frontmostViewController was unexpectedly nil")
return
}
frontmostViewController.present(alert, animated: true, completion: nil)

View File

@ -17,7 +17,7 @@ public class OWSFlatButton: UIView {
override public var backgroundColor: UIColor? {
willSet {
owsFail("Use setBackgroundColors(upColor:) instead.")
owsFailDebug("Use setBackgroundColors(upColor:) instead.")
}
}
@ -157,7 +157,7 @@ public class OWSFlatButton: UIView {
@objc
public func setPressedBlock(_ pressedBlock: @escaping () -> Void) {
guard self.pressedBlock == nil else {
owsFail("Button already has pressed block.")
owsFailDebug("Button already has pressed block.")
return
}
self.pressedBlock = pressedBlock

View File

@ -79,7 +79,7 @@ public class PlayerProgressBar: UIView {
public var player: AVPlayer? {
didSet {
guard let item = player?.currentItem else {
owsFail("No player item")
owsFailDebug("No player item")
return
}
@ -159,7 +159,7 @@ public class PlayerProgressBar: UIView {
@objc
private func handleSliderTouchDown(_ slider: UISlider) {
guard let player = self.player else {
owsFail("player was nil")
owsFailDebug("player was nil")
return
}
@ -184,12 +184,12 @@ public class PlayerProgressBar: UIView {
private func updateState() {
guard let player = player else {
owsFail("player isn't set.")
owsFailDebug("player isn't set.")
return
}
guard let item = player.currentItem else {
owsFail("player has no item.")
owsFailDebug("player has no item.")
return
}
@ -202,7 +202,7 @@ public class PlayerProgressBar: UIView {
let remainingSeconds = CMTimeGetSeconds(remainingTime)
guard let remainingString = formatter.string(from: remainingSeconds) else {
owsFail("unable to format time remaining")
owsFailDebug("unable to format time remaining")
remainingLabel.text = "0:00"
return
}

View File

@ -45,7 +45,7 @@ public class OWSVideoPlayer: NSObject {
OWSAudioSession.shared.startPlaybackAudioActivity(self.audioActivity)
guard let item = avPlayer.currentItem else {
owsFail("video player item was unexpectedly nil")
owsFailDebug("video player item was unexpectedly nil")
return
}

View File

@ -31,7 +31,7 @@ extension String {
func appendingFileExtension(_ fileExtension: String) -> String {
guard let result = (self as NSString).appendingPathExtension(fileExtension) else {
owsFail("Failed to append file extension: \(fileExtension) to string: \(self)")
owsFailDebug("Failed to append file extension: \(fileExtension) to string: \(self)")
return self
}
return result
@ -208,7 +208,7 @@ public class SignalAttachment: NSObject {
public var errorName: String? {
guard let error = error else {
// This method should only be called if there is an error.
owsFail("Missing error")
owsFailDebug("Missing error")
return nil
}
@ -219,11 +219,11 @@ public class SignalAttachment: NSObject {
public var localizedErrorDescription: String? {
guard let error = self.error else {
// This method should only be called if there is an error.
owsFail("Missing error")
owsFailDebug("Missing error")
return nil
}
guard let errorDescription = error.errorDescription else {
owsFail("Missing error description")
owsFailDebug("Missing error description")
return nil
}
@ -233,7 +233,7 @@ public class SignalAttachment: NSObject {
@objc
public class var missingDataErrorMessage: String {
guard let errorDescription = SignalAttachmentError.missingData.errorDescription else {
owsFail("Missing error description")
owsFailDebug("Missing error description")
return ""
}
return errorDescription
@ -264,7 +264,7 @@ public class SignalAttachment: NSObject {
do {
let filePath = mediaUrl.path
guard FileManager.default.fileExists(atPath: filePath) else {
owsFail("asset at \(filePath) doesn't exist")
owsFailDebug("asset at \(filePath) doesn't exist")
return nil
}
@ -516,7 +516,7 @@ public class SignalAttachment: NSObject {
for dataUTI in inputImageUTISet {
if pasteboardUTISet.contains(dataUTI) {
guard let data = dataForFirstPasteboardItem(dataUTI: dataUTI) else {
owsFail("Missing expected pasteboard data for UTI: \(dataUTI)")
owsFailDebug("Missing expected pasteboard data for UTI: \(dataUTI)")
return nil
}
let dataSource = DataSourceValue.dataSource(with: data, utiType: dataUTI)
@ -527,7 +527,7 @@ public class SignalAttachment: NSObject {
for dataUTI in videoUTISet {
if pasteboardUTISet.contains(dataUTI) {
guard let data = dataForFirstPasteboardItem(dataUTI: dataUTI) else {
owsFail("Missing expected pasteboard data for UTI: \(dataUTI)")
owsFailDebug("Missing expected pasteboard data for UTI: \(dataUTI)")
return nil
}
let dataSource = DataSourceValue.dataSource(with: data, utiType: dataUTI)
@ -537,7 +537,7 @@ public class SignalAttachment: NSObject {
for dataUTI in audioUTISet {
if pasteboardUTISet.contains(dataUTI) {
guard let data = dataForFirstPasteboardItem(dataUTI: dataUTI) else {
owsFail("Missing expected pasteboard data for UTI: \(dataUTI)")
owsFailDebug("Missing expected pasteboard data for UTI: \(dataUTI)")
return nil
}
let dataSource = DataSourceValue.dataSource(with: data, utiType: dataUTI)
@ -547,7 +547,7 @@ public class SignalAttachment: NSObject {
let dataUTI = pasteboardUTISet[pasteboardUTISet.startIndex]
guard let data = dataForFirstPasteboardItem(dataUTI: dataUTI) else {
owsFail("Missing expected pasteboard data for UTI: \(dataUTI)")
owsFailDebug("Missing expected pasteboard data for UTI: \(dataUTI)")
return nil
}
let dataSource = DataSourceValue.dataSource(with: data, utiType: dataUTI)
@ -559,15 +559,15 @@ public 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 {
owsFail("Missing expected pasteboard data for UTI: \(dataUTI)")
owsFailDebug("Missing expected pasteboard data for UTI: \(dataUTI)")
return nil
}
guard datas.count > 0 else {
owsFail("Missing expected pasteboard data for UTI: \(dataUTI)")
owsFailDebug("Missing expected pasteboard data for UTI: \(dataUTI)")
return nil
}
guard let data = datas[0] as? Data else {
owsFail("Missing expected pasteboard data for UTI: \(dataUTI)")
owsFailDebug("Missing expected pasteboard data for UTI: \(dataUTI)")
return nil
}
return data
@ -597,7 +597,7 @@ public class SignalAttachment: NSObject {
}
guard dataSource.dataLength() > 0 else {
owsFail("imageData was empty")
owsFailDebug("imageData was empty")
attachment.error = .invalidData
return attachment
}
@ -766,7 +766,7 @@ public class SignalAttachment: NSObject {
// Resizing using a CGContext seems to work fine.
private class func imageScaled(_ uiImage: UIImage, toMaxSize maxSize: CGFloat) -> UIImage? {
guard let cgImage = uiImage.cgImage else {
owsFail("UIImage missing cgImage.")
owsFailDebug("UIImage missing cgImage.")
return nil
}
@ -791,7 +791,7 @@ public class SignalAttachment: NSObject {
bytesPerRow: 0,
space: colorSpace,
bitmapInfo: bitmapInfo.rawValue) else {
owsFail("could not create CGContext.")
owsFailDebug("could not create CGContext.")
return nil
}
context.interpolationQuality = .high
@ -801,7 +801,7 @@ public class SignalAttachment: NSObject {
context.draw(cgImage, in: drawRect)
guard let newCGImage = context.makeImage() else {
owsFail("could not create new CGImage.")
owsFailDebug("could not create new CGImage.")
return nil
}
return UIImage(cgImage: newCGImage,
@ -922,7 +922,7 @@ public class SignalAttachment: NSObject {
}
if !isValidOutputVideo(dataSource: dataSource, dataUTI: dataUTI) {
owsFail("building video with invalid output, migrate to async API using compressVideoAsMp4")
owsFailDebug("building video with invalid output, migrate to async API using compressVideoAsMp4")
}
return newAttachment(dataSource: dataSource,
@ -982,7 +982,7 @@ public class SignalAttachment: NSObject {
guard let dataSource = DataSourcePath.dataSource(with: exportURL,
shouldDeleteOnDeallocation: true) else {
owsFail("Failed to build data source for exported video URL")
owsFailDebug("Failed to build data source for exported video URL")
let attachment = SignalAttachment(dataSource: DataSourceValue.emptyDataSource(), dataUTI: dataUTI)
attachment.error = .couldNotConvertToMpeg4
fulfill(attachment)
@ -1108,7 +1108,7 @@ public class SignalAttachment: NSObject {
@objc
public class func attachment(dataSource: DataSource?, dataUTI: String) -> SignalAttachment {
if inputImageUTISet.contains(dataUTI) {
owsFail("must specify image quality type")
owsFailDebug("must specify image quality type")
}
return attachment(dataSource: dataSource, dataUTI: dataUTI, imageQuality: .original)
}
@ -1162,7 +1162,7 @@ public class SignalAttachment: NSObject {
}
guard dataSource.dataLength() > 0 else {
owsFail("Empty attachment")
owsFailDebug("Empty attachment")
assert(dataSource.dataLength() > 0)
attachment.error = .invalidData
return attachment

View File

@ -17,7 +17,7 @@ public extension String {
while (lowerBoundCharCount < upperBoundCharCount) {
guard let upperBoundData = self.prefix(upperBoundCharCount).data(using: .utf8) else {
owsFail("upperBoundData was unexpectedly nil")
owsFailDebug("upperBoundData was unexpectedly nil")
return nil
}
@ -35,7 +35,7 @@ public extension String {
let midpointString = self.prefix(midpointCharCount)
guard let midpointData = midpointString.data(using: .utf8) else {
owsFail("midpointData was unexpectedly nil")
owsFailDebug("midpointData was unexpectedly nil")
return nil
}
let midpointByteCount = midpointData.count

View File

@ -29,7 +29,7 @@ public extension UIDevice {
return true
default:
// Verify all our IOS_DEVICE_CONSTANT tags make sense when adding a new device size.
owsFail("unknown device format")
owsFailDebug("unknown device format")
return false
}
}

View File

@ -81,7 +81,7 @@ class ContactsFrameworkContactStoreAdaptee: NSObject, ContactStoreAdaptee {
@objc
func runChangeHandler() {
guard let changeHandler = self.changeHandler else {
owsFail("trying to run change handler before it was registered")
owsFailDebug("trying to run change handler before it was registered")
return
}
changeHandler()
@ -100,7 +100,7 @@ class ContactsFrameworkContactStoreAdaptee: NSObject, ContactStoreAdaptee {
systemContacts.append(contact)
}
} catch let error as NSError {
owsFail("Failed to fetch contacts with error:\(error)")
owsFailDebug("Failed to fetch contacts with error:\(error)")
return .error(error)
}
@ -117,13 +117,13 @@ class ContactsFrameworkContactStoreAdaptee: NSObject, ContactStoreAdaptee {
try self.contactStore.enumerateContacts(with: contactFetchRequest) { (contact, _) -> Void in
guard result == nil else {
owsFail("More than one contact with contact id.")
owsFailDebug("More than one contact with contact id.")
return
}
result = contact
}
} catch let error as NSError {
owsFail("Failed to fetch contact with error:\(error)")
owsFailDebug("Failed to fetch contact with error:\(error)")
return nil
}
@ -163,7 +163,7 @@ public class SystemContactsFetcher: NSObject {
@objc
public var isAuthorized: Bool {
guard self.authorizationStatus != .notDetermined else {
owsFail("should have called `requestOnce` before checking authorization status.")
owsFailDebug("should have called `requestOnce` before checking authorization status.")
return false
}
@ -245,7 +245,7 @@ public class SystemContactsFetcher: NSObject {
guard granted else {
// This case should have been caught by the error guard a few lines up.
owsFail("declined contact access.")
owsFailDebug("declined contact access.")
completion(nil)
return
}
@ -282,7 +282,7 @@ public class SystemContactsFetcher: NSObject {
AssertIsOnMainThread()
guard authorizationStatus == .authorized else {
owsFail("should have already requested contact access")
owsFailDebug("should have already requested contact access")
self.delegate?.systemContactsFetcher(self, hasAuthorizationStatus: authorizationStatus)
completion(nil)
return
@ -347,7 +347,7 @@ public class SystemContactsFetcher: NSObject {
}
guard let contacts = fetchedContacts else {
owsFail("contacts was unexpectedly not set.")
owsFailDebug("contacts was unexpectedly not set.")
completion(nil)
}

View File

@ -8,22 +8,22 @@ import SignalServiceKit
public class NoopCallMessageHandler: NSObject, OWSCallMessageHandler {
public func receivedOffer(_ offer: SSKProtoCallMessageOffer, from callerId: String) {
owsFail("")
owsFailDebug("")
}
public func receivedAnswer(_ answer: SSKProtoCallMessageAnswer, from callerId: String) {
owsFail("")
owsFailDebug("")
}
public func receivedIceUpdate(_ iceUpdate: SSKProtoCallMessageIceUpdate, from callerId: String) {
owsFail("")
owsFailDebug("")
}
public func receivedHangup(_ hangup: SSKProtoCallMessageHangup, from callerId: String) {
owsFail("")
owsFailDebug("")
}
public func receivedBusy(_ busy: SSKProtoCallMessageBusy, from callerId: String) {
owsFail("")
owsFailDebug("")
}
}

View File

@ -8,7 +8,7 @@ import SignalServiceKit
public class NoopNotificationsManager: NSObject, NotificationsProtocol {
public func notifyUser(for incomingMessage: TSIncomingMessage, in thread: TSThread, contactsManager: ContactsManagerProtocol, transaction: YapDatabaseReadTransaction) {
owsFail("")
owsFailDebug("")
}
public func notifyUser(for error: TSErrorMessage, thread: TSThread, transaction: YapDatabaseReadWriteTransaction) {

View File

@ -52,7 +52,7 @@ public class OWSAudioSession: NSObject {
do {
try avAudioSession.setCategory(AVAudioSessionCategoryAmbient)
} catch {
owsFail("failed with error: \(error)")
owsFailDebug("failed with error: \(error)")
}
}
@ -69,7 +69,7 @@ public class OWSAudioSession: NSObject {
do {
try avAudioSession.setCategory(AVAudioSessionCategoryPlayback)
} catch {
owsFail("failed with error: \(error)")
owsFailDebug("failed with error: \(error)")
}
}
@ -88,7 +88,7 @@ public class OWSAudioSession: NSObject {
try avAudioSession.setCategory(AVAudioSessionCategoryRecord)
return true
} catch {
owsFail("failed with error: \(error)")
owsFailDebug("failed with error: \(error)")
return false
}
}
@ -151,7 +151,7 @@ public class OWSAudioSession: NSObject {
// By notifying when we deactivate, the other app can resume playback.
try avAudioSession.setActive(false, with: [.notifyOthersOnDeactivation])
} catch {
owsFail("failed with error: \(error)")
owsFailDebug("failed with error: \(error)")
}
}

View File

@ -55,7 +55,7 @@ public class ProfileFetcherJob: NSObject {
if (!CurrentAppContext().isMainApp) {
// Only refresh profiles in the MainApp to decrease the chance of missed SN notifications
// in the AppExtension for our users who choose not to verify contacts.
owsFail("Should only fetch profiles in the main app")
owsFailDebug("Should only fetch profiles in the main app")
return
}

View File

@ -136,7 +136,7 @@ public class ConversationSearcher: NSObject {
let searchResult = ContactSearchResult(signalAccount: signalAccount, contactsManager: contactsManager)
contacts.append(searchResult)
} else {
owsFail("unhandled item: \(match)")
owsFailDebug("unhandled item: \(match)")
}
}
@ -166,7 +166,7 @@ public class ConversationSearcher: NSObject {
case let contactThread as TSContactThread:
return self.contactThreadSearcher.matches(item: contactThread, query: searchText)
default:
owsFail("Unexpected thread type: \(thread)")
owsFailDebug("Unexpected thread type: \(thread)")
return false
}
}

View File

@ -177,7 +177,7 @@ public class ConversationStyle: NSObject {
return bubbleColorOutgoingSent
}
} else {
owsFail("Unexpected message type: \(message)")
owsFailDebug("Unexpected message type: \(message)")
return bubbleColorOutgoingSent
}
}
@ -206,7 +206,7 @@ public class ConversationStyle: NSObject {
} else if message is TSOutgoingMessage {
return ConversationStyle.bubbleTextColorOutgoing
} else {
owsFail("Unexpected message type: \(message)")
owsFailDebug("Unexpected message type: \(message)")
return ConversationStyle.bubbleTextColorOutgoing
}
}

View File

@ -89,7 +89,7 @@ public class LRUCache<KeyType: Hashable & Equatable, ValueType> {
while cacheOrder.count > maxSize {
guard let staleKey = cacheOrder.first else {
owsFail("Cache ordering unexpectedly empty")
owsFailDebug("Cache ordering unexpectedly empty")
return
}
cacheOrder.removeFirst()

View File

@ -53,7 +53,7 @@ import LocalAuthentication
AssertIsOnMainThread()
if !OWSStorage.isStorageReady() {
owsFail("accessed screen lock state before storage is ready.")
owsFailDebug("accessed screen lock state before storage is ready.")
return false
}
@ -74,7 +74,7 @@ import LocalAuthentication
AssertIsOnMainThread()
if !OWSStorage.isStorageReady() {
owsFail("accessed screen lock state before storage is ready.")
owsFailDebug("accessed screen lock state before storage is ready.")
return 0
}
@ -161,7 +161,7 @@ import LocalAuthentication
defaultErrorDescription: defaultErrorDescription)
switch outcome {
case .success:
owsFail("local authentication unexpected success")
owsFailDebug("local authentication unexpected success")
completion(.failure(error:defaultErrorDescription))
case .cancel, .failure, .unexpectedFailure:
completion(outcome)
@ -179,7 +179,7 @@ import LocalAuthentication
defaultErrorDescription: defaultErrorDescription)
switch outcome {
case .success:
owsFail("local authentication unexpected success")
owsFailDebug("local authentication unexpected success")
completion(.failure(error:defaultErrorDescription))
case .cancel, .failure, .unexpectedFailure:
completion(outcome)
@ -241,10 +241,10 @@ import LocalAuthentication
return .failure(error: NSLocalizedString("SCREEN_LOCK_ERROR_LOCAL_AUTHENTICATION_LOCKOUT",
comment: "Indicates that Touch ID/Face ID/Phone Passcode is 'locked out' on this device due to authentication failures."))
case .invalidContext:
owsFail("context not valid.")
owsFailDebug("context not valid.")
return .unexpectedFailure(error:defaultErrorDescription)
case .notInteractive:
owsFail("context not interactive.")
owsFailDebug("context not interactive.")
return .unexpectedFailure(error:defaultErrorDescription)
}
}

View File

@ -22,7 +22,7 @@ public class SwiftSingletons: NSObject {
}
let singletonClassName = String(describing: type(of: singleton))
guard !classSet.contains(singletonClassName) else {
owsFail("Duplicate singleton: \(singletonClassName).")
owsFailDebug("Duplicate singleton: \(singletonClassName).")
return
}
Logger.verbose("Registering singleton: \(singletonClassName).")

View File

@ -45,7 +45,7 @@ class LegacyContactDiscoveryBatchOperation: OWSOperation {
for recipientId in recipientIdsToLookup {
guard let hash = Cryptography.truncatedSHA1Base64EncodedWithoutPadding(recipientId) else {
owsFail("could not hash recipient id: \(recipientId)")
owsFailDebug("could not hash recipient id: \(recipientId)")
continue
}
assert(phoneNumbersByHashes[hash] == nil)
@ -119,17 +119,17 @@ class LegacyContactDiscoveryBatchOperation: OWSOperation {
for contactDict in contactDicts {
guard let hash = contactDict["token"] as? String, hash.count > 0 else {
owsFail("hash was unexpectedly nil")
owsFailDebug("hash was unexpectedly nil")
continue
}
guard let recipientId = phoneNumbersByHashes[hash], recipientId.count > 0 else {
owsFail("recipientId was unexpectedly nil")
owsFailDebug("recipientId was unexpectedly nil")
continue
}
guard recipientIdsToLookup.contains(recipientId) else {
owsFail("unexpected recipientId")
owsFailDebug("unexpected recipientId")
continue
}
@ -187,7 +187,7 @@ class CDSOperation: OWSOperation {
for dependency in self.dependencies {
guard let batchOperation = dependency as? CDSBatchOperation else {
owsFail("unexpected dependency: \(dependency)")
owsFailDebug("unexpected dependency: \(dependency)")
continue
}

View File

@ -60,7 +60,7 @@ public class OutageDetection: NSObject {
} else if addressString == kOutageAddress {
isOutageDetected = true
} else {
owsFail("unexpected address: \(addressString)")
owsFailDebug("unexpected address: \(addressString)")
}
}
}

View File

@ -81,7 +81,7 @@ public class FullTextSearchFinder: NSObject {
public func enumerateObjects(searchText: String, transaction: YapDatabaseReadTransaction, block: @escaping (Any, String) -> Void) {
guard let ext: YapDatabaseFullTextSearchTransaction = ext(transaction: transaction) else {
owsFail("ext was unexpectedly nil")
owsFailDebug("ext was unexpectedly nil")
return
}
@ -178,12 +178,12 @@ public class FullTextSearchFinder: NSObject {
let nationalNumber: String = { (recipientId: String) -> String in
guard let phoneNumber = PhoneNumber(fromE164: recipientId) else {
owsFail("unexpected unparseable recipientId: \(recipientId)")
owsFailDebug("unexpected unparseable recipientId: \(recipientId)")
return ""
}
guard let digitScalars = phoneNumber.nationalNumber?.unicodeScalars.filter({ CharacterSet.decimalDigits.contains($0) }) else {
owsFail("unexpected unparseable recipientId: \(recipientId)")
owsFailDebug("unexpected unparseable recipientId: \(recipientId)")
return ""
}
@ -209,7 +209,7 @@ public class FullTextSearchFinder: NSObject {
}
guard let attachment = message.attachment(with: transaction) else {
owsFail("attachment was unexpectedly nil")
owsFailDebug("attachment was unexpectedly nil")
return nil
}
@ -222,7 +222,7 @@ public class FullTextSearchFinder: NSObject {
}
guard let text = attachmentStream.readOversizeText() else {
owsFail("Could not load oversize text attachment")
owsFailDebug("Could not load oversize text attachment")
return nil
}

View File

@ -21,16 +21,16 @@ public func AssertIsOnMainThread(file: String = #file,
function: String = #function,
line: Int = #line) {
if !Thread.isMainThread {
owsFail("Must be on main thread.", file: file, function: function, line: line)
owsFailDebug("Must be on main thread.", file: file, function: function, line: line)
}
}
// Once we're on Swift4.2 we can mark this as inlineable
// @inlinable
public func owsFail(_ logMessage: String,
file: String = #file,
function: String = #function,
line: Int = #line) {
public func owsFailDebug(_ logMessage: String,
file: String = #file,
function: String = #function,
line: Int = #line) {
Logger.error(logMessage, file: file, function: function, line: line)
Logger.flush()
let formattedMessage = owsFormatLogMessage(logMessage, file: file, function: function, line: line)
@ -39,12 +39,12 @@ public func owsFail(_ logMessage: String,
// Once we're on Swift4.2 we can mark this as inlineable
// @inlinable
public func owsProdExit(_ logMessage: String,
file: String = #file,
function: String = #function,
line: Int = #line) -> Never {
owsFail(logMessage, file: file, function: function, line: line)
public func owsFail(_ logMessage: String,
file: String = #file,
function: String = #function,
line: Int = #line) -> Never {
owsFailDebug(logMessage, file: file, function: function, line: line)
let formattedMessage = owsFormatLogMessage(logMessage, file: file, function: function, line: line)
fatalError(formattedMessage)
}
@ -54,5 +54,6 @@ public func owsProdExit(_ logMessage: String,
public func notImplemented(file: String = #file,
function: String = #function,
line: Int = #line) -> Never {
owsProdExit("Method not implemented.", file: file, function: function, line: line)
owsFail("Method not implemented.", file: file, function: function, line: line)
}

View File

@ -89,7 +89,7 @@ class SAEFailedViewController: UIViewController {
@objc func cancelPressed(sender: UIButton) {
guard let delegate = delegate else {
owsFail("missing delegate")
owsFailDebug("missing delegate")
return
}
delegate.shareViewWasCancelled()

View File

@ -103,7 +103,7 @@ class SAELoadViewController: UIViewController {
@objc func cancelPressed(sender: UIButton) {
guard let delegate = delegate else {
owsFail("missing delegate")
owsFailDebug("missing delegate")
return
}
delegate.shareViewWasCancelled()

View File

@ -354,19 +354,19 @@ public class ShareViewController: UIViewController, ShareViewDelegate, SAEFailed
localeIdentifier.count > 0 {
Logger.info("Locale Identifier: \(localeIdentifier)")
} else {
owsFail("Locale Identifier: Unknown")
owsFailDebug("Locale Identifier: Unknown")
}
if let countryCode = locale.object(forKey: NSLocale.Key.countryCode) as? String,
countryCode.count > 0 {
Logger.info("Country Code: \(countryCode)")
} else {
owsFail("Country Code: Unknown")
owsFailDebug("Country Code: Unknown")
}
if let languageCode = locale.object(forKey: NSLocale.Key.languageCode) as? String,
languageCode.count > 0 {
Logger.info("Language Code: \(languageCode)")
} else {
owsFail("Language Code: Unknown")
owsFailDebug("Language Code: Unknown")
}
}
@ -557,7 +557,7 @@ public class ShareViewController: UIViewController, ShareViewDelegate, SAEFailed
buttonTitle: CommonStrings.cancelButton) { _ in
strongSelf.shareViewWasCancelled()
}
owsFail("building attachment failed with error: \(error)")
owsFailDebug("building attachment failed with error: \(error)")
}.retainUntilComplete()
}
@ -843,7 +843,7 @@ public class ShareViewController: UIViewController, ShareViewDelegate, SAEFailed
progressPoller.startPolling()
guard let loadViewController = strongSelf.loadViewController else {
owsFail("load view controller was unexpectedly nil")
owsFailDebug("load view controller was unexpectedly nil")
return promise
}
@ -933,7 +933,7 @@ private class ProgressPoller: NSObject {
func startPolling() {
guard self.timer == nil else {
owsFail("already started timer")
owsFailDebug("already started timer")
return
}