Permalink
Browse files

fixes #84 fixes #85

  • Loading branch information...
1 parent daefbb8 commit d305a989a5b012d35e9e23192822873861f48fec Alex Billingsley committed Jun 6, 2012
@@ -140,7 +140,8 @@ - (void)getInternal:(NSString *)url requestPreparer:(void(^)(id))requestPreparer
{
block((useOutputStream) ? nil : operation.responseString);
}
- } failure:^(AFHTTPRequestOperation *operation, NSError *error)
+ }
+ failure:^(AFHTTPRequestOperation *operation, NSError *error)
{
#if DEBUG_HTTP_HELPER
NSString *debugOutput = [NSString stringWithFormat:@"Request (%@ %@) failed \n",operation.request.HTTPMethod,[operation.request.URL absoluteString]];
@@ -216,7 +217,8 @@ - (void)postInternal:(NSString *)url requestPreparer:(void(^)(id))requestPrepare
{
block(operation.responseString);
}
- } failure:^(AFHTTPRequestOperation *operation, NSError *error)
+ }
+ failure:^(AFHTTPRequestOperation *operation, NSError *error)
{
#if DEBUG_HTTP_HELPER
NSString *debugOutput = [NSString stringWithFormat:@"Request (%@ %@) failed \n",operation.request.HTTPMethod,[operation.request.URL absoluteString]];
@@ -67,7 +67,7 @@ - (SRSubscription *)subscribe:(NSString *)eventName
{
if([eventName isEqualToString:@""] || eventName == nil)
{
- [NSException raise:@"ArgumentNullException" format:@"Argument %@ is null", @"eventName"];
+ [NSException raise:NSInvalidArgumentException format:NSLocalizedString(@"Argument eventName is null",@"NSInvalidArgumentException")];
}
SRSubscription *subscription = [_subscriptions objectForKey:eventName];
@@ -131,7 +131,7 @@ - (void)invoke:(NSString *)method withArgs:(NSArray *)args continueWith:(void(^)
{
if([method isEqualToString:@""] || method == nil)
{
- [NSException raise:@"ArgumentNullException" format:@"Argument %@ is null", @"method"];
+ [NSException raise:NSInvalidArgumentException format:NSLocalizedString(@"Argument method is null",@"NSInvalidArgumentException")];
}
SRHubInvocation *hubData = [[SRHubInvocation alloc] init];
@@ -155,9 +155,9 @@ - (void)invoke:(NSString *)method withArgs:(NSArray *)args continueWith:(void(^)
if(![hubResult.error isKindOfClass:[NSNull class]] && hubResult.error != nil)
{
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
- [userInfo setObject:[NSString stringWithFormat:@"InvalidOperationException"] forKey:NSLocalizedFailureReasonErrorKey];
+ [userInfo setObject:NSInternalInconsistencyException forKey:NSLocalizedFailureReasonErrorKey];
[userInfo setObject:[NSString stringWithFormat:@"%@",hubResult.error] forKey:NSLocalizedDescriptionKey];
- NSError *error = [NSError errorWithDomain:[NSString stringWithFormat:@"com.SignalR-ObjC.%@",NSStringFromClass([self class])]
+ NSError *error = [NSError errorWithDomain:[NSString stringWithFormat:NSLocalizedString(@"com.SignalR-ObjC.%@",@""),NSStringFromClass([self class])]
code:0
userInfo:userInfo];
[_connection didReceiveError:error];
@@ -58,7 +58,7 @@ - (id)initWithMajor:(NSInteger)major minor:(NSInteger)minor
if(_major < 0 || _minor < 0)
{
- [NSException raise:@"ArgumentOutOfRangeException" format:@"Component cannot be less than 0"];
+ [NSException raise:NSInvalidArgumentException format:NSLocalizedString(@"Component cannot be less than 0",@"NSInvalidArgumentException")];
}
}
return self;
@@ -72,7 +72,7 @@ - (id)initWithMajor:(NSInteger)major minor:(NSInteger)minor build:(NSInteger)bui
if(_build < 0)
{
- [NSException raise:@"ArgumentOutOfRangeException" format:@"Component cannot be less than 0"];
+ [NSException raise:NSInvalidArgumentException format:NSLocalizedString(@"Component cannot be less than 0",@"NSInvalidArgumentException")];
}
}
return self;
@@ -86,7 +86,7 @@ - (id)initWithMajor:(NSInteger)major minor:(NSInteger)minor build:(NSInteger)bui
if(_revision < 0)
{
- [NSException raise:@"ArgumentOutOfRangeException" format:@"Component cannot be less than 0"];
+ [NSException raise:NSInvalidArgumentException format:NSLocalizedString(@"Component cannot be less than 0",@"NSInvalidArgumentException")];
}
}
return self;
@@ -104,7 +104,7 @@ - (id)initWithURL:(NSString *)url queryString:(NSString *)queryString
NSRange range = [queryString rangeOfString:@"?" options:NSCaseInsensitiveSearch];
if(range.location != NSNotFound)
{
- [NSException raise:@"ArgumentException" format:@"Url cannot contain QueryString directly. Pass QueryString values in using available overload."];
+ [NSException raise:NSInvalidArgumentException format:NSLocalizedString(@"Url cannot contain QueryString directly. Pass QueryString values in using available overload.",@"")];
}
if([url hasSuffix:@"/"] == false){
@@ -196,7 +196,7 @@ - (void)verifyProtocolVersion:(NSString *)versionString
![SRVersion tryParse:versionString forVersion:&version] ||
!(version.major == 1 && version.minor == 0))
{
- [NSException raise:@"InvalidOperationException" format:@"Incompatible Protocol Version"];
+ [NSException raise:NSInternalInconsistencyException format:NSLocalizedString(@"Incompatible Protocol Version",@"NSInternalInconsistencyException")];
}
}
@@ -242,9 +242,9 @@ - (void)send:(NSString *)message continueWith:(void (^)(id response))block
if (!_initialized)
{
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
- [userInfo setObject:[NSString stringWithFormat:@"InvalidOperationException"] forKey:NSLocalizedFailureReasonErrorKey];
- [userInfo setObject:[NSString stringWithFormat:@"Start must be called before data can be sent"] forKey:NSLocalizedDescriptionKey];
- NSError *error = [NSError errorWithDomain:[NSString stringWithFormat:@"com.SignalR-ObjC.%@",NSStringFromClass([self class])]
+ [userInfo setObject:NSInternalInconsistencyException forKey:NSLocalizedFailureReasonErrorKey];
+ [userInfo setObject:[NSString stringWithFormat:NSLocalizedString(@"Start must be called before data can be sent",@"NSInternalInconsistencyException")] forKey:NSLocalizedDescriptionKey];
+ NSError *error = [NSError errorWithDomain:[NSString stringWithFormat:NSLocalizedString(@"com.SignalR-ObjC.%@",@""),NSStringFromClass([self class])]
code:0
userInfo:userInfo];
[self didReceiveError:error];
@@ -308,9 +308,9 @@ - (void)prepareRequest:(id)request
if([request isKindOfClass:[NSMutableURLRequest class]])
{
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
- [request addValue:[self createUserAgentString:@"SignalR.Client.iOS"] forHTTPHeaderField:@"User-Agent"];
+ [request addValue:[self createUserAgentString:NSLocalizedString(@"SignalR.Client.iOS",@"")] forHTTPHeaderField:@"User-Agent"];
#elif TARGET_OS_MAC
- [request addValue:[self createUserAgentString:@"SignalR.Client.OSX"] forHTTPHeaderField:@"User-Agent"];
+ [request addValue:[self createUserAgentString:NSLocalizedString(@"SignalR.Client.OSX",@"")] forHTTPHeaderField:@"User-Agent"];
#endif
if(_credentials != nil)
{
@@ -84,9 +84,9 @@ - (void)resolveTransport:(SRConnection *)connection data:(NSString *)data taskCo
else
{
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
- [userInfo setObject:[NSString stringWithFormat:@"TransportInitializeException"] forKey:NSLocalizedFailureReasonErrorKey];
- [userInfo setObject:[NSString stringWithFormat:@"No transport could be initialized successfully. Try specifying a different transport or none at all for auto initialization."] forKey:NSLocalizedDescriptionKey];
- NSError *error = [NSError errorWithDomain:[NSString stringWithFormat:@"com.SignalR-ObjC.%@",NSStringFromClass([self class])]
+ [userInfo setObject:NSInternalInconsistencyException forKey:NSLocalizedFailureReasonErrorKey];
+ [userInfo setObject:[NSString stringWithFormat:NSLocalizedString(@"No transport could be initialized successfully. Try specifying a different transport or none at all for auto initialization.",@"")] forKey:NSLocalizedDescriptionKey];
+ NSError *error = [NSError errorWithDomain:[NSString stringWithFormat:NSLocalizedString(@"com.SignalR-ObjC.%@",@""),NSStringFromClass([self class])]
code:0
userInfo:userInfo];
[connection didReceiveError:error];
@@ -120,7 +120,7 @@ - (void)start:(SRConnection *)connection withData:(NSString *)data continueWith:
- (void)onStart:(SRConnection *)connection data:(NSString *)data initializeCallback:(void (^)(void))initializeCallback errorCallback:(void (^)(SRErrorByReferenceBlock))errorCallback
{
- [NSException raise:@"AbstractClassException" format:@"Must use an overriding class of DKHttpBasedTransport"];
+ [NSException raise:NSGenericException format:NSLocalizedString(@"Must use an overriding class of SRHttpBasedTransport",@"")];
}
- (void)send:(SRConnection *)connection withData:(NSString *)data continueWith:(void (^)(id response))block
@@ -621,9 +621,9 @@ - (void)openConnection:(SRConnection *)connection data:(NSString *)data initiali
SRErrorByReferenceBlock errorBlock = ^(NSError ** error)
{
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
- [userInfo setObject:[NSString stringWithFormat:@"TimeoutException"] forKey:NSLocalizedFailureReasonErrorKey];
- [userInfo setObject:[NSString stringWithFormat:@"Transport took longer than %d to connect",_connectionTimeout] forKey:NSLocalizedDescriptionKey];
- *error = [NSError errorWithDomain:[NSString stringWithFormat:@"com.SignalR-ObjC.%@",NSStringFromClass([self class])]
+ [userInfo setObject:NSInternalInconsistencyException forKey:NSLocalizedFailureReasonErrorKey];
+ [userInfo setObject:[NSString stringWithFormat:NSLocalizedString(@"Transport took longer than %d to connect",@""),_connectionTimeout] forKey:NSLocalizedDescriptionKey];
+ *error = [NSError errorWithDomain:[NSString stringWithFormat:NSLocalizedString(@"com.SignalR-ObjC.%@",@""),NSStringFromClass([self class])]
code:NSURLErrorTimedOut
userInfo:userInfo];
};

0 comments on commit d305a98

Please sign in to comment.