I would like to have some feedback from client developers. How do you handle errors coming from Moodle web service?
Do you display eh error message directly to the user? Do you check which error message you are receiving, and then display custom error message? Do you display a generic error message?
I think that at the moment Moodle web service are not very error friendly because it's hard for the client developer to customize the error message. I think Moodle should always return a not translated error message and let the developer manage it.
What do you think?
I wrote a document about error handling in the Moodle web service: http://docs.moodle.org/dev/Errors_handling_in_web_services#Issue
Currently the Java library throws an error up to the software the developer has written for them to catch with the error text from the function reply as the message. There are some errors thrown by the library before the call is made such as checking for required parameters. Various other internal errors get sent as log entries to the console.
I think it's important to distinguish between errors for which an exception should be thrown (e.g the user does not have appropriate access rights to call the function) and errors for which a warning message should be returned together with the results (e.g the user is requesting information for a list of courses and one of those courses in no longer available).
In the second case, the function would return the requested information for all courses except one. A warning message is included in the results for the course that is no longer available.
I think that it's necessary return a custom error code for every type of blocking error. For example, an error code for invalid login credential = 300, or user haven't the right permission for take an action = 320, ...
In this way, the client can get the number of the code and take the appropriate action, regarless the lang of the application.
Morehover if there are other and more specific information about the error (for example, error updating a record field couse malformat parameter) these information should be passes always to the client in a debug field, in the same way as the moodle exception or the database exception.