-
Bug
-
Resolution: Fixed
-
Minor
-
3.5.4, 3.6.2, 3.7
-
MOODLE_35_STABLE, MOODLE_36_STABLE, MOODLE_37_STABLE
-
MOODLE_35_STABLE, MOODLE_36_STABLE
-
MDL-64961-master -
An error handler in REST web services is supposed to turn exceptions into nice JSON format error messages. This code works correctly only for moodle_exception; for other exceptions, on certain platforms/PHP settings (on my Windows PC with PHP 7.2; not on my RHEL developer server with PHP 7.1), it causes a fatal error because it tries to access the 'errorcode' property which does not exist..
As Moodle code mainly only throws moodle_exception this is usually not a problem but it can happen if Moodle code calls library code that may throw an exception; also, in PHP 7+, various system errors are now thrown as exceptions/errors.
This can make it harder to diagnose problems e.g. in the mobile app (or anything else calling REST web services) because the returned value doesn't contain any mention of the exception, and nor does the server log; it just logs the fatal error...
I propose changing it to behave the same as debuginfo, so that if there is no errorcode, it doesn't get included in the JSON value.