I am working on handling error received from Parse.com while performing log in in my IOS app. I try logging in with wrong password and correct username using AFNetworking
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
NSDictionary *parameters = @{my parameters};
[manager POST:@"{login url}" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
code
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error.localizedDescription); <-- this line gets processed
}];
The log says
Request failed: not found (404)
I know that means wrong password, but shouldn't it be more descriptive? How do I handle other error (like Bad Request)? Shouldn't the user knows why the request failed or is a bad one?
EDIT: This is the response from Parse when I tried to login with the wrong password
{
AFNetworkingOperationFailingURLResponseErrorKey = "<NSHTTPURLResponse: 0x15571820> { URL: https://api.parse.com/1/login?password=pqpqpq&username=lalala%20namaku%20panjang%20sekali%20lhoooooooooooo } { status code: 404, headers {\n \"Access-Control-Allow-Origin\" = \"*\";\n \"Access-Control-Request-Method\" = \"*\";\n Connection = \"keep-alive\";\n \"Content-Encoding\" = gzip;\n \"Content-Length\" = 68;\n \"Content-Type\" = \"application/json; charset=utf-8\";\n Date = \"Wed, 16 Jul 2014 05:49:49 GMT\";\n Server = \"nginx/1.4.4\";\n \"X-Parse-Platform\" = G1;\n \"X-Runtime\" = \"0.113695\";\n} }";
NSErrorFailingURLKey = "https://api.parse.com/1/login?password=pqpqpq&username=lalala%20namaku%20panjang%20sekali%20lhoooooooooooo";
NSLocalizedDescription = "Request failed: not found (404)";
}
How do I know that this means the User object that match the username and password is not found, OR the URL (https://api.parse.com/1/login?password=pqpqpq&username=lalala%20namaku%20panjang%20sekali%20lhoooooooooooo) that is not found?