Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.

Commit 4557474

Browse files
committed
Better reporting of login problems
1 parent 6f4def8 commit 4557474

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

runestone/common/js/runestonebase.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,15 @@ export default class RunestoneBase {
137137
if (!response.ok) {
138138
if (response.status === 422) {
139139
// Get details about why this is unprocesable.
140-
post_return = await response.json()
141-
console.log(post_return.detail)
140+
post_return = await response.json();
141+
console.log(post_return.detail);
142+
throw new Error("Unprocessable Request");
143+
} else if (response.status == 401) {
144+
post_return = await response.json();
145+
console.log(
146+
`Missing authentication token ${post_return.detail}`
147+
);
148+
throw new Error("Missing authentication token");
142149
}
143150
throw new Error("Failed to save the log entry");
144151
}
@@ -212,7 +219,10 @@ export default class RunestoneBase {
212219
this.checkServerComplete = new Promise(function (resolve, reject) {
213220
self.csresolver = resolve;
214221
});
215-
if (eBookConfig.isLoggedIn && (this.useRunestoneServices || this.graderactive)) {
222+
if (
223+
eBookConfig.isLoggedIn &&
224+
(this.useRunestoneServices || this.graderactive)
225+
) {
216226
let data = {};
217227
data.div_id = this.divid;
218228
data.course = eBookConfig.course;
@@ -225,8 +235,10 @@ export default class RunestoneBase {
225235
if (this.sid) {
226236
data.sid = this.sid;
227237
}
228-
if (! (data.div_id && data.course && data.event) ) {
229-
console.log(`A required field is missing data ${data.div_id}:${data.course}:${data.event}`)
238+
if (!(data.div_id && data.course && data.event)) {
239+
console.log(
240+
`A required field is missing data ${data.div_id}:${data.course}:${data.event}`
241+
);
230242
}
231243
// If we are NOT in practice mode and we are not in a peer exercise
232244
// and assessmentTaken is true

0 commit comments

Comments
 (0)