From 5909810b1fd00cacd3a4b52d0dd13ef36bc15177 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Thu, 4 Aug 2016 17:38:54 -0400 Subject: [PATCH] Improve error handling of msg move/copy actions --- UI/MailerUI/UIxMailFolderActions.m | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/UI/MailerUI/UIxMailFolderActions.m b/UI/MailerUI/UIxMailFolderActions.m index 07d5bd34d..1ddb51700 100644 --- a/UI/MailerUI/UIxMailFolderActions.m +++ b/UI/MailerUI/UIxMailFolderActions.m @@ -431,7 +431,7 @@ destinationFolder = [data objectForKey: @"folder"]; response = nil; - if ([uids count] > 0) + if ([uids count] > 0 && destinationFolder) { response = [co copyUIDs: uids toFolder: destinationFolder inContext: context]; if (!response) @@ -446,6 +446,12 @@ else response = [self responseWithStatus: 200]; } + else + { + data = [NSDictionary dictionaryWithObject: [(NSException *)response reason] + forKey: @"message"]; + response = [self responseWithStatus: 500 andJSONRepresentation: data]; + } } else { @@ -477,7 +483,7 @@ destinationFolder = [data objectForKey: @"folder"]; response = nil; - if ([uids count] > 0) + if ([uids count] > 0 && destinationFolder) { response = [co moveUIDs: uids toFolder: destinationFolder inContext: context]; if (!response) @@ -501,10 +507,16 @@ } response = [self responseWith204]; } + else + { + data = [NSDictionary dictionaryWithObject: [(NSException *)response reason] + forKey: @"message"]; + response = [self responseWithStatus: 500 andJSONRepresentation: data]; + } } else { - data = [NSDictionary dictionaryWithObject: [self labelForKey: @"Error moving messages." inContext: context] + data = [NSDictionary dictionaryWithObject: @"Error 'uids' and/or 'folder' parameters." forKey: @"message"]; response = [self responseWithStatus: 500 andJSONRepresentation: data]; }