diff --git a/assets/src/containers/Course.js b/assets/src/containers/Course.js index ee7e2a42..392f72e7 100644 --- a/assets/src/containers/Course.js +++ b/assets/src/containers/Course.js @@ -55,9 +55,24 @@ function Course (props) { setSideDrawerState(open) } - if (error.message === 'Not Found') return (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.) - else if (error.message === 'Forbidden') return (You do not have access to course {courseId}.) - else if (error) return () + if (error.message === '404' || error.message === 'Not Found') { + return ( + + 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. + + ) + } + else if (error.message === '403' || error.message === 'Forbidden') { + return ( + + You do not have access to course {courseId}. + + ) + } + else if (error) { + return () + } + if (loaded && isObjectEmpty(courseInfo)) return (My Learning Analytics is not enabled for this course.) const notLoadedAltMessage = 'Mouse running on wheel with text "Course Data Being Processed, Try Back in 24 Hours"' diff --git a/assets/src/util/data.js b/assets/src/util/data.js index f2a8b849..442bf43e 100644 --- a/assets/src/util/data.js +++ b/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 }