Instrument network errors.

// FREEBIE
pull/1/head
Matthew Chen 8 years ago
parent 117bca7c48
commit 9587aab37b

@ -34,6 +34,10 @@ static NSString *const OWS103EnableVideoCallingMigrationId = @"103";
[self save];
}
failure:^(NSURLSessionDataTask *task, NSError *error) {
if (!IsNSErrorNetworkFailure(error)) {
OWSProdErrorWNSError(
@"error_enable_video_calling_request_failed", error);
}
DDLogError(@"%@ failed with error: %@", self.tag, error);
}];
}];

@ -115,23 +115,7 @@
return [thisVersionString compare:thatVersionString options:NSNumericSearch] == NSOrderedAscending;
}
#pragma mark Upgrading to 2.1 - Needs to register VOIP token + Removing video cache folder
+ (void)nonBlockingPushRegistration {
void (^failedBlock)(NSError *) = ^(NSError *error) {
DDLogError(@"Failed to register VOIP push token: %@", error.debugDescription);
};
[[PushManager sharedManager] requestPushTokenWithSuccess:^(NSString *pushToken, NSString *voipToken) {
[[TSAccountManager sharedInstance]
registerForPushNotificationsWithPushToken:pushToken
voipToken:voipToken
success:^{
DDLogWarn(@"Registered for VOIP Push.");
}
failure:failedBlock];
}
failure:failedBlock];
}
#pragma mark Upgrading to 2.1 - Removing video cache folder
+ (void)clearVideoCache {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
@ -166,6 +150,9 @@
dispatch_semaphore_signal(sema);
}
failure:^(NSURLSessionDataTask *task, NSError *error) {
if (!IsNSErrorNetworkFailure(error)) {
OWSProdErrorWNSError(@"error_update_attributes_request_failed", error);
}
success = NO;
DDLogError(@"Updating attributess failed with error: %@", error.description);
dispatch_semaphore_signal(sema);

@ -159,6 +159,9 @@ NSString *const kNSNotificationName_LocalNumberDidChange = @"kNSNotificationName
failure:failureHandler
remainingRetries:remainingRetries - 1];
} else {
if (!IsNSErrorNetworkFailure(error)) {
OWSProdErrorWNSError(@"accounts_error_register_push_tokens_failed", error);
}
failureHandler(error);
}
}];
@ -193,6 +196,9 @@ NSString *const kNSNotificationName_LocalNumberDidChange = @"kNSNotificationName
successBlock();
}
failure:^(NSURLSessionDataTask *task, NSError *error) {
if (!IsNSErrorNetworkFailure(error)) {
OWSProdErrorWNSError(@"accounts_error_verification_code_request_failed", error);
}
DDLogError(@"%@ Failed to request verification code request with error:%@", self.tag, error);
failureBlock(error);
}];
@ -263,6 +269,9 @@ NSString *const kNSNotificationName_LocalNumberDidChange = @"kNSNotificationName
}
}
failure:^(NSURLSessionDataTask *task, NSError *error) {
if (!IsNSErrorNetworkFailure(error)) {
OWSProdErrorWNSError(@"accounts_error_verify_account_request_failed", error);
}
DDLogWarn(@"%@ Error verifying code: %@", self.tag, error.debugDescription);
switch (error.code) {
case 403: {
@ -316,6 +325,9 @@ NSString *const kNSNotificationName_LocalNumberDidChange = @"kNSNotificationName
userInfo:nil];
}
failure:^(NSURLSessionDataTask *task, NSError *error) {
if (!IsNSErrorNetworkFailure(error)) {
OWSProdErrorWNSError(@"accounts_error_unregister_account_request_failed", error);
}
DDLogError(@"%@ Failed to unregister with error: %@", self.tag, error);
failureBlock(error);
}];

@ -181,11 +181,13 @@ static const NSTimeInterval kSignedPreKeyUpdateFailureMaxFailureDuration = 10 *
[TSPreKeyManager clearPreKeyUpdateFailureCount];
}
failure:^(NSURLSessionDataTask *task, NSError *error) {
if (!IsNSErrorNetworkFailure(error)) {
if (modeCopy == RefreshPreKeysMode_SignedAndOneTime) {
OWSProdErrorWNSError(@"error_prekeys_update_failed_signed_and_onetime", error);
} else {
OWSProdErrorWNSError(@"error_prekeys_update_failed_just_signed", error);
}
}
// Mark the prekeys as _NOT_ checked on failure.
[self markPreKeysAsNotChecked];
@ -302,6 +304,9 @@ static const NSTimeInterval kSignedPreKeyUpdateFailureMaxFailureDuration = 10 *
}
}
failure:^(NSURLSessionDataTask *task, NSError *error) {
if (!IsNSErrorNetworkFailure(error)) {
OWSProdErrorWNSError(@"error_prekeys_current_signed_prekey_request_failed", error);
}
DDLogWarn(@"%@ Could not retrieve current signed key from the service.", self.tag);
// Mark the prekeys as _NOT_ checked on failure.
@ -310,6 +315,9 @@ static const NSTimeInterval kSignedPreKeyUpdateFailureMaxFailureDuration = 10 *
}
}
failure:^(NSURLSessionDataTask *task, NSError *error) {
if (!IsNSErrorNetworkFailure(error)) {
OWSProdErrorWNSError(@"error_prekeys_available_prekeys_request_failed", error);
}
DDLogError(@"%@ Failed to retrieve the number of available prekeys.", self.tag);
// Mark the prekeys as _NOT_ checked on failure.

@ -188,8 +188,8 @@ NS_ASSUME_NONNULL_BEGIN
[[TSStorageManager sharedManager].dbReadWriteConnection
readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
for (NSString *identifier in attributesForIdentifier) {
SignalRecipient *recipient =
[SignalRecipient recipientWithTextSecureIdentifier:identifier withTransaction:transaction];
SignalRecipient *recipient = [SignalRecipient recipientWithTextSecureIdentifier:identifier
withTransaction:transaction];
if (!recipient) {
recipient = [[SignalRecipient alloc] initWithTextSecureIdentifier:identifier relay:nil];
}
@ -205,6 +205,10 @@ NS_ASSUME_NONNULL_BEGIN
success([NSSet setWithArray:attributesForIdentifier.allKeys]);
}
failure:^(NSURLSessionDataTask *task, NSError *error) {
if (!IsNSErrorNetworkFailure(error)) {
OWSProdErrorWNSError(@"contacts_error_contacts_intersection_failed", error);
}
NSHTTPURLResponse *response = (NSHTTPURLResponse *)task.response;
if (response.statusCode == 413) {
failure(OWSErrorWithCodeDescription(

@ -145,15 +145,13 @@ static const CGFloat kAttachmentDownloadProgressTheta = 0.001f;
[self.networkManager makeRequest:attachmentRequest
success:^(NSURLSessionDataTask *task, id responseObject) {
if (![responseObject isKindOfClass:[NSDictionary class]]) {
DDLogError(@"%@ Failed retrieval of attachment. Response had unexpected format.",
self.tag);
DDLogError(@"%@ Failed retrieval of attachment. Response had unexpected format.", self.tag);
NSError *error = OWSErrorMakeUnableToProcessServerResponseError();
return markAndHandleFailure(error);
}
NSString *location = [(NSDictionary *)responseObject objectForKey:@"location"];
if (!location) {
DDLogError(
@"%@ Failed retrieval of attachment. Response had no location.", self.tag);
DDLogError(@"%@ Failed retrieval of attachment. Response had no location.", self.tag);
NSError *error = OWSErrorMakeUnableToProcessServerResponseError();
return markAndHandleFailure(error);
}
@ -188,6 +186,9 @@ static const CGFloat kAttachmentDownloadProgressTheta = 0.001f;
});
}
failure:^(NSURLSessionDataTask *task, NSError *error) {
if (!IsNSErrorNetworkFailure(error)) {
OWSProdErrorWNSError(@"error_attachment_request_failed", error);
}
DDLogError(@"Failed retrieval of attachment with error: %@", error);
if (attachment.serverId < 100) {
// This _shouldn't_ be the symptom of the "frequent 404

@ -1216,6 +1216,9 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
dispatch_semaphore_signal(sema);
}
failure:^(NSURLSessionDataTask *task, NSError *error) {
if (!IsNSErrorNetworkFailure(error)) {
OWSProdErrorWNSError(@"message_sender_error_recipient_prekey_request_failed", error);
}
DDLogError(@"Server replied to PreKeyBundle request with error: %@", error);
NSHTTPURLResponse *response = (NSHTTPURLResponse *)task.response;
if (response.statusCode == 404) {

@ -1,4 +1,6 @@
// Copyright © 2016 Open Whisper Systems. All rights reserved.
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "OWSDeviceProvisioningCodeService.h"
#import "OWSDeviceProvisioningCodeRequest.h"
@ -48,6 +50,9 @@ NSString *const OWSDeviceProvisioningCodeServiceProvisioningCodeKey = @"verifica
}
}
failure:^(NSURLSessionDataTask *task, NSError *error) {
if (!IsNSErrorNetworkFailure(error)) {
OWSProdErrorWNSError(@"error_provisioning_code_request_failed", error);
}
DDLogVerbose(@"ProvisioningCode request failed with error: %@", error);
failureCallback(error);
}];

@ -1,4 +1,6 @@
// Copyright © 2016 Open Whisper Systems. All rights reserved.
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "OWSDeviceProvisioningService.h"
#import "OWSDeviceProvisioningRequest.h"
@ -45,6 +47,9 @@ NS_ASSUME_NONNULL_BEGIN
successCallback();
}
failure:^(NSURLSessionDataTask *task, NSError *error) {
if (!IsNSErrorNetworkFailure(error)) {
OWSProdErrorWNSError(@"error_provisioning_request_failed", error);
}
DDLogVerbose(@"Provisioning request failed with error: %@", error);
failureCallback(error);
}];

@ -1,4 +1,6 @@
// Copyright © 2016 Open Whisper Systems. All rights reserved.
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "OWSDevicesService.h"
#import "OWSDeleteDeviceRequest.h"
@ -30,6 +32,9 @@ NS_ASSUME_NONNULL_BEGIN
}
}
failure:^(NSURLSessionDataTask *task, NSError *error) {
if (!IsNSErrorNetworkFailure(error)) {
OWSProdErrorWNSError(@"error_get_devices_failed", error);
}
DDLogVerbose(@"Get devices request failed with error: %@", error);
failureCallback(error);
}];
@ -47,6 +52,9 @@ NS_ASSUME_NONNULL_BEGIN
successCallback();
}
failure:^(NSURLSessionDataTask *task, NSError *error) {
if (!IsNSErrorNetworkFailure(error)) {
OWSProdErrorWNSError(@"error_unlink_device_failed", error);
}
DDLogVerbose(@"Get devices request failed with error: %@", error);
failureCallback(error);
}];

@ -26,6 +26,8 @@ NS_ASSUME_NONNULL_BEGIN
extern NSString *const TSNetworkManagerDomain;
BOOL IsNSErrorNetworkFailure(NSError *_Nullable error);
@interface TSNetworkManager : NSObject
- (instancetype)init NS_UNAVAILABLE;

@ -12,6 +12,11 @@
NSString *const TSNetworkManagerDomain = @"org.whispersystems.signal.networkManager";
BOOL IsNSErrorNetworkFailure(NSError *_Nullable error)
{
return ([error.domain isEqualToString:TSNetworkManagerDomain] && error.code == 0);
}
@interface TSNetworkManager ()
typedef void (^failureBlock)(NSURLSessionDataTask *task, NSError *error);

Loading…
Cancel
Save