Handle exception when saving calendar properties

pull/229/merge
Francis Lachapelle 2018-08-31 09:31:18 -04:00
parent 87df69163f
commit eeec8328c0
1 changed files with 67 additions and 52 deletions

View File

@ -1,6 +1,6 @@
/* UIxCalendarProperties.m - this file is part of SOGo
*
* Copyright (C) 2008-2015 Inverse inc.
* Copyright (C) 2008-2018 Inverse inc.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -21,8 +21,10 @@
#import <Foundation/NSDictionary.h>
#import <Foundation/NSValue.h>
#import <NGObjWeb/NSException+HTTP.h>
#import <NGObjWeb/WORequest.h>
#import <SOGo/NSDictionary+Utilities.h>
#import <SOGo/NSString+Utilities.h>
#import <Appointments/SOGoWebAppointmentFolder.h>
@ -73,12 +75,16 @@
- (WOResponse *) savePropertiesAction
{
WORequest *request;
NSDictionary *params;
WOResponse *response;
NSDictionary *params, *message;
id o, values;
request = [context request];
params = [[request contentAsString] objectFromJSONString];
response = [self responseWith204];
NS_DURING
{
o = [params objectForKey: @"name"];
if ([o isKindOfClass: [NSString class]])
[calendar renameTo: o];
@ -130,8 +136,17 @@
if ([o isKindOfClass: [NSString class]])
[calendar setNotifiedUserOnPersonalModifications: o];
}
}
NS_HANDLER
{
message = [NSDictionary dictionaryWithObject: [localException reason] forKey: @"message"];
response = [self responseWithStatus: 400 /* Bad Request */
andString: [message jsonRepresentation]];
return [self responseWith204];
}
NS_ENDHANDLER;
return response;
}
@end