From bb29f5620bb498b4f3a80fee352d102aa4999171 Mon Sep 17 00:00:00 2001 From: helge Date: Mon, 18 Jul 2005 13:28:13 +0000 Subject: [PATCH] improved error handling git-svn-id: http://svn.opengroupware.org/SOGo/trunk@791 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOGo/UI/MailerUI/ChangeLog | 6 +++ SOGo/UI/MailerUI/UIxMailListView.m | 61 +++++++++++++++++++++--------- SOGo/UI/MailerUI/Version | 2 +- 3 files changed, 51 insertions(+), 18 deletions(-) diff --git a/SOGo/UI/MailerUI/ChangeLog b/SOGo/UI/MailerUI/ChangeLog index a4852eb7..a9b01e8d 100644 --- a/SOGo/UI/MailerUI/ChangeLog +++ b/SOGo/UI/MailerUI/ChangeLog @@ -1,3 +1,9 @@ +2005-07-18 Helge Hess + + * UIxMailListView.m: improved error handling (display a JavaScript + alert panel showing the issue instead of SOPE exception rendering) + (v0.9.146) + 2005-07-18 Marcus Mueller * UIxMailToSelection.m: changed behavior for adding/removing text diff --git a/SOGo/UI/MailerUI/UIxMailListView.m b/SOGo/UI/MailerUI/UIxMailListView.m index c499e3d0..0963ce34 100644 --- a/SOGo/UI/MailerUI/UIxMailListView.m +++ b/SOGo/UI/MailerUI/UIxMailListView.m @@ -425,6 +425,27 @@ static int attachmentFlagSize = 8096; return script; } +/* error redirects */ + +- (id)redirectToViewWithError:(id)_error { + // TODO: improve, localize + // TODO: there is a bug in the treeview which preserves the current URL for + // the active object (displaying the error again) + id url; + + if (![_error isNotNull]) + return [self redirectToLocation:@"view"]; + + if ([_error isKindOfClass:[NSException class]]) + _error = [_error reason]; + else if ([_error isKindOfClass:[NSString class]]) + _error = [_error stringValue]; + + url = [_error stringByEscapingURL]; + url = [@"view?error=" stringByAppendingString:url]; + return [self redirectToLocation:url]; +} + /* active message */ - (SOGoMailObject *)lookupActiveMessage { @@ -524,15 +545,17 @@ static int attachmentFlagSize = 8096; id client; if ((client = [self clientObject]) == nil) { - return [NSException exceptionWithHTTPStatus:404 /* Not Found */ - reason:@"did not find mail folder"]; + error = [NSException exceptionWithHTTPStatus:404 /* Not Found */ + reason:@"did not find mail folder"]; + return [self redirectToViewWithError:error]; } if (![client isKindOfClass:NSClassFromString(@"SOGoTrashFolder")]) { /* would be better to move the method to an own class, but well .. */ - return [NSException exceptionWithHTTPStatus:400 /* Bad Request */ - reason:@"method cannot be invoked on " - @"the specified object"]; + error = [NSException exceptionWithHTTPStatus:400 /* Bad Request */ + reason:@"method cannot be invoked on " + @"the specified object"]; + return [self redirectToViewWithError:error]; } /* mark all as deleted */ @@ -542,13 +565,13 @@ static int attachmentFlagSize = 8096; error = [[self clientObject] addFlagsToAllMessages:@"deleted"]; if (error != nil) // TODO: improve error - return error; + return [self redirectToViewWithError:error]; /* expunge */ if ((error = [[self clientObject] expunge]) != nil) // TODO: improve error - return error; + return [self redirectToViewWithError:error]; if ([client respondsToSelector:@selector(flushMailCaches)]) [client flushMailCaches]; @@ -564,18 +587,21 @@ static int attachmentFlagSize = 8096; folderName = [[[self context] request] formValueForKey:@"name"]; if ([folderName length] == 0) { - return [NSException exceptionWithHTTPStatus:400 /* Bad Request */ - reason:@"missing 'name' query parameter!"]; + error = [NSException exceptionWithHTTPStatus:400 /* Bad Request */ + reason:@"missing 'name' query parameter!"]; + return [self redirectToViewWithError:error]; } - + if ((client = [self clientObject]) == nil) { - return [NSException exceptionWithHTTPStatus:404 /* Not Found */ - reason:@"did not find mail folder"]; + error = [NSException exceptionWithHTTPStatus:404 /* Not Found */ + reason:@"did not find mail folder"]; + return [self redirectToViewWithError:error]; } if ((error = [[self clientObject] davCreateCollection:folderName - inContext:[self context]]) != nil) - return error; + inContext:[self context]]) != nil) { + return [self redirectToViewWithError:error]; + } return [self redirectToLocation:[folderName stringByAppendingString:@"/"]]; } @@ -586,8 +612,9 @@ static int attachmentFlagSize = 8096; id client; if ((client = [self clientObject]) == nil) { - return [NSException exceptionWithHTTPStatus:404 /* Not Found */ - reason:@"did not find mail folder"]; + error = [NSException exceptionWithHTTPStatus:404 /* Not Found */ + reason:@"did not find mail folder"]; + return [self redirectToViewWithError:error]; } /* jump to parent folder afterwards */ @@ -595,7 +622,7 @@ static int attachmentFlagSize = 8096; if (![url hasSuffix:@"/"]) url = [url stringByAppendingString:@"/"]; if ((error = [[self clientObject] delete]) != nil) - return error; + return [self redirectToViewWithError:error]; return [self redirectToLocation:url]; } diff --git a/SOGo/UI/MailerUI/Version b/SOGo/UI/MailerUI/Version index d4e4663d..7f736d49 100644 --- a/SOGo/UI/MailerUI/Version +++ b/SOGo/UI/MailerUI/Version @@ -1,6 +1,6 @@ # version file -SUBMINOR_VERSION:=145 +SUBMINOR_VERSION:=146 # v0.9.140 requires SoObjects/Mailer v0.9.100 # v0.9.134 requires libSOGo v0.9.41 -- 2.39.5