Commit d358d67d authored by Francois Gannaz's avatar Francois Gannaz
Browse files

addInstance(): better handling of lnb API error

parent fb91dabf
......@@ -70,7 +70,11 @@ function labnbook_add_instance($moduleinstance, $mform = null) {
} catch (\Exception $e) {
die("fatal error: " . $e->getMessage()); // TODO
}
$moduleinstance->labnbook_teamconfigid = (int) $teamConfig->id_team_config;
if ($teamConfig->id_team_config) {
$moduleinstance->labnbook_teamconfigid = (int) $teamConfig->id_team_config;
} else {
throw new moodle_exception("LabnBook return an invalid response.");
}
$moduleinstance->timecreated = time();
$id = $DB->insert_record(LABNBOOK_TABLE, $moduleinstance);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment