How to handle Parse.com Rest API error when using AFNetworking 2.0

I am working on handling an error received from Parse.com while logging into my iOS app. I am trying to log in with the wrong password and correct the 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 magazine says:

Request failed: not found (404)

I know this means a wrong password, but shouldn't be more descriptive? How do I handle another error (e.g. Bad Request)? Should the user not know why the request was unsuccessful or bad?

EDIT: This is a 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)";
}

, , User, , , URL (https://api.parse.com/1/login?password=pqpqpq&username=lalala%20namaku%20panjang%20sekali%20lhoooooooooooo) ?

+4
1

http- 404, json-, { "code": 101, "error": "invalid login parameters" },

( http://parse.com/docs/dotnet/api/html/T_Parse_ParseException_ErrorCode.htm). URL- , , . https://parse.com/docs/rest#users-login CURL, , URL- , JSON .

, HTTP 404 AFNetworking 2.0 AFHTTPSessionManager: JSON ?

+4

Source: https://habr.com/ru/post/1548331/


All Articles