Revision ef59aa75 pithos-macos/PithosUtilities.m

b/pithos-macos/PithosUtilities.m
1188 1188
#pragma mark Alerts
1189 1189

  
1190 1190
+ (void)httpRequestErrorAlertWithRequest:(ASIPithosRequest *)request {
1191
    if (request.responseStatusCode == 401) {
1192
        [self httpAuthenticationError];
1193
        return;
1194
    }
1191 1195
    NSString *message = [NSString stringWithFormat:
1192 1196
                         @"HTTP request error: %@\n%@ URL: %@\nRequest Headers: %@\nResponse Headers: %@\nResponse String: %@", 
1193 1197
                         [[request error] localizedDescription], 
......
1209 1213
}
1210 1214

  
1211 1215
+ (void)unexpectedResponseStatusAlertWithRequest:(ASIPithosRequest *)request {
1216
    if (request.responseStatusCode == 401) {
1217
        [self httpAuthenticationError];
1218
        return;
1219
    }
1212 1220
    NSString *message = [NSString stringWithFormat:
1213 1221
                         @"Unexpected response status %d: %@\n%@ URL: %@\nRequest Headers: %@\nResponse Headers: %@\nResponse String: %@", 
1214 1222
                         request.responseStatusCode, 
......
1230 1238
    });
1231 1239
}
1232 1240

  
1241
+ (void)httpAuthenticationError {
1242
    dispatch_async(dispatch_get_main_queue(), ^{
1243
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
1244
        NSAlert *alert = [[[NSAlert alloc] init] autorelease];
1245
        [alert setMessageText:@"Authentication Error"];
1246
        [alert setInformativeText:@"Authentication error, please check your token or login again"];
1247
        [alert addButtonWithTitle:@"OK"];
1248
        [alert runModal];
1249
        [pool drain];
1250
    });
1251
}
1252

  
1233 1253
+ (void)fileActionFailedAlertWithTitle:(NSString *)title message:(NSString *)message error:(NSError *)error {
1234 1254
    dispatch_async(dispatch_get_main_queue(), ^{
1235 1255
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

Also available in: Unified diff