Skip to content

Commit 61a2f99

Browse files
committed
Fix for data to return status if statusText is not available
1 parent ad755c0 commit 61a2f99

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

assets/src/containers/Course.js

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

58-
if (error.message === 'Not Found' || (error.message === "")) {
58+
if (error.message === '404' || error.message === 'Not Found') {
5959
return (
6060
<WarningBanner>
6161
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.
6262
</WarningBanner>
6363
)
6464
}
65-
else if (error.message === 'Forbidden') {
65+
else if (error.message === '403' || error.message === 'Forbidden') {
6666
return (
6767
<WarningBanner>
6868
You do not have access to course {courseId}.

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)