Skip to content

Commit dabeaf6

Browse files
committed
Improve error message for invalid metadata
1 parent 93926d5 commit dabeaf6

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

markus-jupyter-extension/static/extension.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ define(["require", "base/js/namespace", "base/js/dialog"], function (
3333
logo.width = "16";
3434
new_group.firstChild.prepend(logo);
3535
}
36+
3637
/**
3738
* Submit the currently open file to MarkUs. Relies on the following notebook metadata:
3839
* "markus": {
@@ -154,26 +155,26 @@ define(["require", "base/js/namespace", "base/js/dialog"], function (
154155
*/
155156
function validateMetadata(metadata) {
156157
if (metadata["markus"] === undefined) {
157-
throw 'Notebook metadata is missing the "markus" key.';
158+
throw 'Notebook metadata is missing the "markus" key. Please check the metadata under Edit -> Edit Notebook Metadata.';
158159
}
159160

160161
let { url, course_id, assessment_id } = metadata["markus"];
161162

162163
if (!url || !course_id || !assessment_id) {
163-
throw 'Notebook metadata is missing one or more of the following keys under "markus": "url", "course_id", or "assessment_id".';
164+
throw 'Notebook metadata is missing one or more of the following keys under "markus": "url", "course_id", or "assessment_id". Please check the metadata under Edit -> Edit Notebook Metadata.';
164165
}
165166

166167
course_id = parseInt(course_id);
167168
assessment_id = parseInt(assessment_id);
168169

169170
if (isNaN(course_id) || isNaN(assessment_id)) {
170-
throw 'Notebook metadata "course_id" and "assessment_id" values must be numbers.';
171+
throw 'Notebook metadata "course_id" and "assessment_id" values must be numbers. Please check the metadata under Edit -> Edit Notebook Metadata.';
171172
}
172173

173174
try {
174175
new URL(url);
175176
} catch {
176-
throw 'Notebook metatdata "url" value did not specify a valid URL.';
177+
throw 'Notebook metatdata "url" value did not specify a valid URL. Please check the metadata under Edit -> Edit Notebook Metadata.';
177178
}
178179
}
179180

0 commit comments

Comments
 (0)