Skip to content

Commit 0464082

Browse files
committed
Improve error handling on structure
1 parent 88e0aa6 commit 0464082

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

structure/functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ function print_ws_structure($wsname, $type, $structure, $useparams) {
135135
* Login required: " . ($structure->loginrequired ? 'yes' : 'no');*/
136136
echo "
137137
*/
138-
${export}type $type = ".convert_to_ts(null, $typestructure).";\n";
138+
{$export}type $type = ".convert_to_ts(null, $typestructure).";\n";
139139
}
140140

141141
/**

structure/ws_functions.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,18 @@ function get_all_ws_structures() {
3535
$functions = $DB->get_records('external_functions', array('services' => 'moodle_mobile_app'), 'name');
3636
$functiondescs = array();
3737
foreach ($functions as $function) {
38-
$functiondescs[$function->name] = external_api::external_function_info($function);
38+
try {
39+
$functiondescs[$function->name] = external_api::external_function_info($function);
40+
} catch (Exception $e) {
41+
// Fake response to see errors.
42+
$functiondescs[$function->name] = new StdClass();
43+
$functiondescs[$function->name]->parameters_desc = null;
44+
$functiondescs[$function->name]->returns_desc = null;
45+
$functiondescs[$function->name]->description = $exception->getMessage();
46+
$functiondescs[$function->name]->loginrequired = null;
47+
$functiondescs[$function->name]->allowed_from_ajax = null;
48+
$functiondescs[$function->name]->readonlysession = null;
49+
}
3950
}
4051

4152
return $functiondescs;

0 commit comments

Comments
 (0)