Skip to content

Commit

Permalink
Improve error handling on structure
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyserver committed Nov 29, 2024
1 parent 88e0aa6 commit 0464082
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion structure/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}

/**
Expand Down
13 changes: 12 additions & 1 deletion structure/ws_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 $e) {
// 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;
Expand Down

0 comments on commit 0464082

Please sign in to comment.