Hi Kyle,
nice module.
A few thoughts on the error handling though.
On line 87 or so add some more watchdog calling and make changes so the error codes from services get returned. This will always return the error codes (if generated by the service) into the #error key in connResult. Also this version maintains the dictionary that ends up in #data with the #error and the #message. Having the #error in the top level of connresult makes it much easier to take action on the error.
>
$result = services_method_call($request['method'], $args);
// watchdog the result
if(variable_get('plist_server_debug_mode', 0)) {
watchdog('plist_server', 'result: ' . $request['method'] . ': ' . print_r($result, 1));
}
if (is_array($result) && ($result['#error'] != 0)) {
return plist_server_encode_plist(array('#error' => $result['#error'], '#data' => $result, '#method' => $request, '#args' => $args));
}
<For example this makes it easy to catch errors such 'User already logged in'. Previously I had to check the type of the #data returned on some calls because #data would be an NSNumber if all was good and if in error #data would be a NSDictionary.
Kind of related but I have modified the iOS SDK as well which I will push back to git some later, which makes it a bit more consistent in its return vales and error. Same with the DIOS Demo App.
Thanks for the great module.
Comments
Comment #1
kylebrowning commentedOk cool i look forward to seeing the changes to DIOS although i this example code, what happens if error is TRUE? Does nothing get returned?
Comment #2
psy commentedHi,
when #error is set to TRUE, in Objective C you get a 1 or YES or TRUE depending on how you want to read it. But a 1 doesn't tell you much. If #error is FALSE, then you get a zero/NO/false which in this case is all you need to know.
If #error is a code from Services (say 406) then code like this becomes really useful.
In this case the code 406 is being returned from Services user.login service.
I hope this helps
John
Comment #3
kylebrowning commentedThis project is feature frozen as services 3.x is much more powerful and has way better error handling.