Closed
Description
Looking at the code, it seems like SDK is using the code property of ParseException to represent many different things:
- libcurl's internal error codes
- HTTP status codes
- Parse REST API error codes
I understand that these sets of values do not overlap (curl uses code values 0-99). But most of the time, SDK does not assign the exception code at all. This inconsistency makes writing exception handling code very hard, as your only option is to parse the exception message string in order to determine what exactly went wrong.
This can be most notably seen in ParseUser class:
if (!$username) {
throw new ParseException('Cannot log in user with an empty name');
}
According to http://docs.parseplatform.org/php/guide/#error-codes the above code should set exception code to 200:
if (!$username) {
throw new ParseException('Cannot log in user with an empty name', 200);
}