]> err.no Git - scalable-opengroupware.org/blobdiff - SOGo/UI/MailerUI/UIxMailView.m
improved error handling in mail-view
[scalable-opengroupware.org] / SOGo / UI / MailerUI / UIxMailView.m
index 917feebe67b2777b0ca4d41e5f891cc45b226c52..ffe89b1101fde8bbeefeddf2116c3320dbcd9ea0 100644 (file)
   return NO;
 }
 
+- (id)redirectToParentFolder {
+  id url;
+  
+  url = [[[self clientObject] container] baseURLInContext:[self context]];
+  return [self redirectToLocation:url];
+}
+
 - (id)deleteAction {
   NSException *ex;
-  
+
   if (![self isDeletableClientObject]) {
     return [NSException exceptionWithHTTPStatus:400 /* Bad Request */
                         reason:@"method cannot be invoked on "
                                @"the specified object"];
   }
   
+  if ([self isInvokedBySafeMethod]) {
+    // TODO: fix UI to use POST for unsafe actions
+    [self logWithFormat:@"WARNING: method is invoked using safe HTTP method!"];
+  }
+  
   if ((ex = [[self clientObject] delete]) != nil) {
     // TODO: improve error handling
+    id url;
+    
     [self debugWithFormat:@"failed to delete: %@", ex];
-    return ex;
+    
+    url = [[ex reason] stringByEscapingURL];
+    url = [@"view?error=" stringByAppendingString:url];
+    return [self redirectToLocation:url];
+    //return ex;
   }
   
   if (![self isInlineViewer]) {
     [page takeValue:@"YES" forKey:@"refreshOpener"];
     return page;
   }
-  else {
-    id url;
-
-    url = [[[self clientObject] container] baseURLInContext:[self context]];
-    return [self redirectToLocation:url];
-  }
+  
+  return [self redirectToParentFolder];
 }
 
 - (id)getMailAction {