Fix JSON error responses

pull/229/merge
Francis Lachapelle 2018-08-30 21:51:39 -04:00
parent bad8efca47
commit 18df3bafb5
5 changed files with 13 additions and 13 deletions

View File

@ -84,7 +84,7 @@
if ([owner isEqualToString: login])
{
jsonResponse = [NSDictionary dictionaryWithObject: [self labelForKey: @"You cannot (un)subscribe to a folder that you own!"]
forKey: @"error"];
forKey: @"message"];
response = [self responseWithStatus: 403
andJSONRepresentation: jsonResponse];
}
@ -294,7 +294,7 @@
}
else
{
message = [NSDictionary dictionaryWithObject: @"Missing name parameter" forKey: @"error"];
message = [NSDictionary dictionaryWithObject: @"Missing name parameter" forKey: @"message"];
response = [self responseWithStatus: 500
andString: [message jsonRepresentation]];
}
@ -335,7 +335,7 @@
{
response = [self responseWithStatus: 400
andJSONRepresentation: [NSDictionary dictionaryWithObject: @"At least 1 id required."
forKey: @"error"]];
forKey: @"message"]];
}
return response;

View File

@ -103,7 +103,7 @@
if (response)
{
data = [NSDictionary dictionaryWithObjectsAndKeys: [(NSException *) response reason], @"error", nil];
data = [NSDictionary dictionaryWithObjectsAndKeys: [(NSException *) response reason], @"message", nil];
response = [self responseWithStatus: 403
andJSONRepresentation: data];
}

View File

@ -79,14 +79,14 @@
}
else
{
data = [NSDictionary dictionaryWithObjectsAndKeys: @"That name already exists", @"error", nil];
data = [NSDictionary dictionaryWithObjectsAndKeys: @"That name already exists", @"message", nil];
response = [self responseWithStatus: 409
andString: [data jsonRepresentation]];
}
}
else
{
data = [NSDictionary dictionaryWithObjectsAndKeys: @"The name is missing", @"error", nil];
data = [NSDictionary dictionaryWithObjectsAndKeys: @"The name is missing", @"message", nil];
response = [self responseWithStatus: 400
andString: [data jsonRepresentation]];
}

View File

@ -217,7 +217,7 @@
if (![self _initRights])
{
jsonResponse = [NSDictionary dictionaryWithObject: [self labelForKey: @"No such user."]
forKey: @"error"];
forKey: @"message"];
response = [self responseWithStatus: 403
andString: [jsonResponse jsonRepresentation]];
}
@ -274,7 +274,7 @@
if (!([self _initRightsForUserID: currentUid]))
{
jsonResponse = [NSDictionary dictionaryWithObject: [self labelForKey: @"No such user."]
forKey: @"error"];
forKey: @"message"];
response = [self responseWithStatus: 403
andString: [jsonResponse jsonRepresentation]];
break;

View File

@ -85,14 +85,14 @@
{
errorFormat = [self labelForKey: @"The folder with name \"%@\" could not be created." inContext: context];
jsonResponse = [NSDictionary dictionaryWithObject: [NSString stringWithFormat: errorFormat, folderName]
forKey: @"error"];
forKey: @"message"];
response = [self responseWithStatus: 500 andJSONRepresentation: jsonResponse];
}
}
else
{
jsonResponse = [NSDictionary dictionaryWithObject: [self labelForKey: @"Missing 'name' parameter." inContext: context]
forKey: @"error"];
forKey: @"message"];
response = [self responseWithStatus: 500 andJSONRepresentation: jsonResponse];
}
@ -401,7 +401,7 @@
if (error)
{
jsonResponse = [NSDictionary dictionaryWithObject: [self labelForKey: @"Unable to move/delete folder." inContext: context]
forKey: @"error"];
forKey: @"message"];
response = [self responseWithStatus: 500 andJSONRepresentation: jsonResponse];
}
else
@ -428,7 +428,7 @@
if (error)
{
jsonResponse = [NSDictionary dictionaryWithObject: [self labelForKey: @"Unable to move/delete folder." inContext: context]
forKey: @"error"];
forKey: @"message"];
response = [self responseWithStatus: 500 andJSONRepresentation: jsonResponse];
}
else
@ -993,7 +993,7 @@
{
result = [NSDictionary dictionaryWithObject: [self labelForKey: @"Missing 'flags' and 'msgUIDs' parameters."
inContext: context]
forKey: @"error"];
forKey: @"message"];
response = [self responseWithStatus: 500 andJSONRepresentation: result];
}
else