Skip to content

Commit 2e98435

Browse files
zqianjonespm
andauthored
issue #1540 issue_1540 empty error message was returned when student invokes MyLA before fully setup (#1561)
* issue #1540 issue_1540 empty error message was returned when student invokes MyLA before fully setup * Update Course.js with formatting changes * Fix for data to return status if statusText is not available --------- Co-authored-by: Code Hugger (Matthew Jones) <jonespm@umich.edu>
1 parent 7c2ac2d commit 2e98435

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

assets/src/containers/Course.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,24 @@ function Course (props) {
5555
setSideDrawerState(open)
5656
}
5757

58-
if (error.message === 'Not Found') return (<WarningBanner>Course {courseId} has not been set up in MyLA. Contact your instructor, who can enable the visualizations by clicking on MyLA in the course navigation.</WarningBanner>)
59-
else if (error.message === 'Forbidden') return (<WarningBanner>You do not have access to course {courseId}.</WarningBanner>)
60-
else if (error) return (<WarningBanner />)
58+
if (error.message === '404' || error.message === 'Not Found') {
59+
return (
60+
<WarningBanner>
61+
Course {courseId} has not been set up in MyLA. Contact your instructor, who can enable the visualizations by clicking on MyLA in the course navigation.
62+
</WarningBanner>
63+
)
64+
}
65+
else if (error.message === '403' || error.message === 'Forbidden') {
66+
return (
67+
<WarningBanner>
68+
You do not have access to course {courseId}.
69+
</WarningBanner>
70+
)
71+
}
72+
else if (error) {
73+
return (<WarningBanner />)
74+
}
75+
6176
if (loaded && isObjectEmpty(courseInfo)) return (<WarningBanner>My Learning Analytics is not enabled for this course.</WarningBanner>)
6277

6378
const notLoadedAltMessage = 'Mouse running on wheel with text "Course Data Being Processed, Try Back in 24 Hours"'

assets/src/util/data.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import Cookie from 'js-cookie'
22

33
const handleError = res => {
4-
if (!res.ok) throw Error(res.statusText)
4+
if (!res.ok) {
5+
// Return the statusText or if it's empty just return the status
6+
// This is to preserve existing behavior where statusText was returned but isn't always available
7+
throw Error(res.statusText || res.status.toString())
8+
}
59
return res
610
}
711

0 commit comments

Comments
 (0)