+ (void)httpRequestErrorAlertWithRequest:(ASIPithosRequest *)request;
+ (void)unexpectedResponseStatusAlertWithRequest:(ASIPithosRequest *)request;
++ (void)httpAuthenticationError;
+ (void)fileActionFailedAlertWithTitle:(NSString *)title message:(NSString *)message error:(NSError *)error;
+ (ASIPithosRequest *)prepareRequest:(ASIPithosRequest *)request priority:(NSOperationQueuePriority)priority;
#pragma mark Alerts
+ (void)httpRequestErrorAlertWithRequest:(ASIPithosRequest *)request {
+ if (request.responseStatusCode == 401) {
+ [self httpAuthenticationError];
+ return;
+ }
NSString *message = [NSString stringWithFormat:
@"HTTP request error: %@\n%@ URL: %@\nRequest Headers: %@\nResponse Headers: %@\nResponse String: %@",
[[request error] localizedDescription],
}
+ (void)unexpectedResponseStatusAlertWithRequest:(ASIPithosRequest *)request {
+ if (request.responseStatusCode == 401) {
+ [self httpAuthenticationError];
+ return;
+ }
NSString *message = [NSString stringWithFormat:
@"Unexpected response status %d: %@\n%@ URL: %@\nRequest Headers: %@\nResponse Headers: %@\nResponse String: %@",
request.responseStatusCode,
});
}
++ (void)httpAuthenticationError {
+ dispatch_async(dispatch_get_main_queue(), ^{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ NSAlert *alert = [[[NSAlert alloc] init] autorelease];
+ [alert setMessageText:@"Authentication Error"];
+ [alert setInformativeText:@"Authentication error, please check your token or login again"];
+ [alert addButtonWithTitle:@"OK"];
+ [alert runModal];
+ [pool drain];
+ });
+}
+
+ (void)fileActionFailedAlertWithTitle:(NSString *)title message:(NSString *)message error:(NSError *)error {
dispatch_async(dispatch_get_main_queue(), ^{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];