dropbox errors now display error summary
This commit is contained in:
parent
a41b939b99
commit
b2aed3d958
@ -102,16 +102,22 @@
|
||||
options:0
|
||||
error:nil]
|
||||
isEqualToDictionary:@{}]) {
|
||||
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
[SharedDeclerations
|
||||
presentErrorAlert:
|
||||
[NSError errorWithDomain:DropboxErrorDomain
|
||||
[NSError
|
||||
errorWithDomain:DropboxErrorDomain
|
||||
code:100
|
||||
userInfo:@{
|
||||
DropboxErrorUserInfo :
|
||||
NSLocalizedDescriptionKey
|
||||
}]
|
||||
userInfo:
|
||||
[[NSJSONSerialization
|
||||
JSONObjectWithData:data
|
||||
options:0
|
||||
error:nil]
|
||||
valueForKey:
|
||||
DropboxErrorUserInfo]]
|
||||
|
||||
presenter:presenter];
|
||||
}];
|
||||
}
|
||||
|
||||
}];
|
||||
@ -122,7 +128,6 @@
|
||||
* Pass nil as path for root dir
|
||||
* @param completion executed after completion
|
||||
*/
|
||||
// TODO: Alert on Dropbox error
|
||||
- (void)contentsOfPath:(NSString *)path
|
||||
completion:(void (^)(NSArray *data))handler
|
||||
presenter:(UIViewController *)presenter
|
||||
@ -160,7 +165,7 @@
|
||||
|
||||
[NSURLConnection
|
||||
sendAsynchronousRequest:request
|
||||
queue:[NSOperationQueue mainQueue]
|
||||
queue:[[NSOperationQueue alloc] init]
|
||||
completionHandler:^(NSURLResponse *response, NSData *data,
|
||||
NSError *error) {
|
||||
if (data != nil) {
|
||||
@ -168,7 +173,31 @@
|
||||
options:0
|
||||
error:nil];
|
||||
if ([data isKindOfClass:[NSDictionary class]]) {
|
||||
handler([data valueForKey:@"entries"]);
|
||||
NSArray *data2 = [data valueForKey:@"entries"];
|
||||
if (data2 == nil) {
|
||||
[[NSOperationQueue
|
||||
mainQueue] addOperationWithBlock:^{
|
||||
[SharedDeclerations
|
||||
presentErrorAlert:
|
||||
[NSError
|
||||
errorWithDomain:DropboxErrorDomain
|
||||
code:100
|
||||
userInfo:
|
||||
[[NSJSONSerialization
|
||||
JSONObjectWithData:
|
||||
data
|
||||
options:
|
||||
0
|
||||
error:
|
||||
nil]
|
||||
valueForKey:
|
||||
DropboxErrorUserInfo]]
|
||||
presenter:presenter];
|
||||
}];
|
||||
}
|
||||
else {
|
||||
handler(data2);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (error != nil) {
|
||||
@ -182,7 +211,6 @@
|
||||
}];
|
||||
}
|
||||
|
||||
// TODO: Alert on Dropbox error
|
||||
- (void)downloadFromDropbox:(NSArray *)files
|
||||
presenter:(UIViewController *)presenter
|
||||
{
|
||||
@ -221,10 +249,36 @@
|
||||
completionHandler:^(NSURLResponse *response, NSData *data,
|
||||
NSError *error) {
|
||||
if (error == nil) {
|
||||
if ([[NSJSONSerialization JSONObjectWithData:data
|
||||
options:0
|
||||
error:nil]
|
||||
valueForKey:@"error_summary"] == nil) {
|
||||
[data writeToFile:[SharedDeclerations
|
||||
savePathForFile:string]
|
||||
atomically:YES];
|
||||
}
|
||||
else {
|
||||
[[NSOperationQueue
|
||||
mainQueue] addOperationWithBlock:^{
|
||||
[SharedDeclerations
|
||||
presentErrorAlert:
|
||||
[NSError
|
||||
errorWithDomain:DropboxErrorDomain
|
||||
code:100
|
||||
userInfo:
|
||||
[[NSJSONSerialization
|
||||
JSONObjectWithData:
|
||||
data
|
||||
options:
|
||||
0
|
||||
error:
|
||||
nil]
|
||||
valueForKey:
|
||||
DropboxErrorUserInfo]]
|
||||
presenter:presenter];
|
||||
}];
|
||||
}
|
||||
}
|
||||
else if (error != nil) {
|
||||
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
|
||||
@ -238,7 +292,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Alert on Dropbox error
|
||||
- (void)uploadToDropbox:(NSArray *)files presenter:(UIViewController *)presenter
|
||||
{
|
||||
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
|
||||
@ -287,6 +340,26 @@
|
||||
|
||||
}];
|
||||
}
|
||||
if ([[NSJSONSerialization JSONObjectWithData:data
|
||||
options:0
|
||||
error:nil]
|
||||
valueForKey:@"error_summary"] != nil) {
|
||||
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
[SharedDeclerations
|
||||
presentErrorAlert:
|
||||
[NSError
|
||||
errorWithDomain:DropboxErrorDomain
|
||||
code:100
|
||||
userInfo:
|
||||
[[NSJSONSerialization
|
||||
JSONObjectWithData:data
|
||||
options:0
|
||||
error:nil]
|
||||
valueForKey:
|
||||
DropboxErrorUserInfo]]
|
||||
presenter:presenter];
|
||||
}];
|
||||
}
|
||||
}];
|
||||
}
|
||||
}
|
||||
@ -294,7 +367,6 @@
|
||||
#pragma mark - Other operations
|
||||
|
||||
// !!!: Cannot be asynchronous
|
||||
// TODO: Alert on Dropbox error
|
||||
- (NSDictionary *)getUserInfoWithPresenter:(UIViewController *)presenter
|
||||
{
|
||||
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
|
||||
@ -319,8 +391,27 @@
|
||||
returningResponse:&response
|
||||
error:&error2]];
|
||||
if ([data isKindOfClass:[NSDictionary class]]) {
|
||||
if ([[NSJSONSerialization JSONObjectWithData:data options:0 error:nil]
|
||||
valueForKey:@"error_summary"] == nil) {
|
||||
return data;
|
||||
}
|
||||
else {
|
||||
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
[SharedDeclerations
|
||||
presentErrorAlert:
|
||||
[NSError errorWithDomain:DropboxErrorDomain
|
||||
code:100
|
||||
userInfo:[[NSJSONSerialization
|
||||
JSONObjectWithData:data
|
||||
options:0
|
||||
error:nil]
|
||||
valueForKey:
|
||||
DropboxErrorUserInfo]]
|
||||
presenter:presenter];
|
||||
}];
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
else if (error != nil) {
|
||||
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
|
||||
|
||||
@ -13,8 +13,7 @@
|
||||
NSString *const FMCNEXTRTEPAGE = @"NEXTRTEPAGE";
|
||||
NSString *const FMCFIRSTRTEPAGE = @"FIRSTRTEPAGE";
|
||||
NSString *const DropboxErrorDomain = @"com.weebly.alikja.FMC";
|
||||
NSString *const DropboxErrorUserInfo =
|
||||
@"Dropbox API Error. Please try again later!";
|
||||
NSString *const DropboxErrorUserInfo = @"error_summary";
|
||||
|
||||
#pragma mark - Adaptive font size method
|
||||
|
||||
|
||||
@ -55,7 +55,9 @@ DropboxV2ObjC *dbClient = nil;
|
||||
[NSPredicate
|
||||
predicateWithFormat:@"NOT (SELF BEGINSWITH %@)",
|
||||
@"."]] mutableCopy];
|
||||
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
[self.tableView reloadData];
|
||||
}];
|
||||
}
|
||||
presenter:self];
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user