From 026f01af417110e9d2c058f16e211a5524df685d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Fri, 29 Nov 2024 12:45:09 +0100 Subject: [PATCH] Improve error handling on structure --- structure/functions.php | 2 +- structure/ws_functions.php | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/structure/functions.php b/structure/functions.php index b02a02f4..f0eb2935 100644 --- a/structure/functions.php +++ b/structure/functions.php @@ -135,7 +135,7 @@ function print_ws_structure($wsname, $type, $structure, $useparams) { * Login required: " . ($structure->loginrequired ? 'yes' : 'no');*/ echo " */ -${export}type $type = ".convert_to_ts(null, $typestructure).";\n"; +{$export}type $type = ".convert_to_ts(null, $typestructure).";\n"; } /** diff --git a/structure/ws_functions.php b/structure/ws_functions.php index bbdf3105..4db78fa3 100644 --- a/structure/ws_functions.php +++ b/structure/ws_functions.php @@ -35,7 +35,18 @@ function get_all_ws_structures() { $functions = $DB->get_records('external_functions', array('services' => 'moodle_mobile_app'), 'name'); $functiondescs = array(); foreach ($functions as $function) { - $functiondescs[$function->name] = external_api::external_function_info($function); + try { + $functiondescs[$function->name] = external_api::external_function_info($function); + } catch (Exception $exception) { + // Fake response to see errors. + $functiondescs[$function->name] = new StdClass(); + $functiondescs[$function->name]->parameters_desc = null; + $functiondescs[$function->name]->returns_desc = null; + $functiondescs[$function->name]->description = $exception->getMessage(); + $functiondescs[$function->name]->loginrequired = null; + $functiondescs[$function->name]->allowed_from_ajax = null; + $functiondescs[$function->name]->readonlysession = null; + } } return $functiondescs;