Skip to content

Commit

Permalink
issue #1540 issue_1540 empty error message was returned when student …
Browse files Browse the repository at this point in the history
…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>
  • Loading branch information
zqian and jonespm committed Jan 25, 2024
1 parent 7c2ac2d commit 2e98435
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
21 changes: 18 additions & 3 deletions assets/src/containers/Course.js
Expand Up @@ -55,9 +55,24 @@ function Course (props) {
setSideDrawerState(open)
}

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>)
else if (error.message === 'Forbidden') return (<WarningBanner>You do not have access to course {courseId}.</WarningBanner>)
else if (error) return (<WarningBanner />)
if (error.message === '404' || 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>
)
}
else if (error.message === '403' || error.message === 'Forbidden') {
return (
<WarningBanner>
You do not have access to course {courseId}.
</WarningBanner>
)
}
else if (error) {
return (<WarningBanner />)
}

if (loaded && isObjectEmpty(courseInfo)) return (<WarningBanner>My Learning Analytics is not enabled for this course.</WarningBanner>)

const notLoadedAltMessage = 'Mouse running on wheel with text "Course Data Being Processed, Try Back in 24 Hours"'
Expand Down
6 changes: 5 additions & 1 deletion assets/src/util/data.js
@@ -1,7 +1,11 @@
import Cookie from 'js-cookie'

const handleError = res => {
if (!res.ok) throw Error(res.statusText)
if (!res.ok) {
// Return the statusText or if it's empty just return the status
// This is to preserve existing behavior where statusText was returned but isn't always available
throw Error(res.statusText || res.status.toString())
}
return res
}

Expand Down

0 comments on commit 2e98435

Please sign in to comment.