Skip to content

Commit dd5d304

Browse files
Show appropriate error message if member haven't access to private challenges
1 parent 2f8dc7d commit dd5d304

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/reducers/challenge.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,18 @@ function onGetDetailsInit(state, action) {
5252
function onGetDetailsDone(state, action) {
5353
if (action.error) {
5454
logger.error('Failed to get challenge details!', action.payload);
55-
fireErrorMessage(
56-
'ERROR: Failed to load the challenge',
57-
'Please, try again a bit later',
58-
);
55+
if (action.payload.message === 'Forbidden') {
56+
fireErrorMessage(
57+
'ERROR: Private challenge',
58+
'This challenge is only available to those in a private group.'
59+
+ ' It looks like you do not have access to this challenge.',
60+
);
61+
} else {
62+
fireErrorMessage(
63+
'ERROR: Failed to load the challenge',
64+
'Please, try again a bit later',
65+
);
66+
}
5967
return {
6068
...state,
6169
fetchChallengeFailure: action.error,

src/services/challenges.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ async function checkErrorV5(res) {
138138
if (res.status >= 500) {
139139
setErrorIcon(ERROR_ICON_TYPES.API, '/challenges', res.statusText);
140140
}
141-
throw new Error(res.statusText);
141+
throw new Error((!res.statusText && res.status === 403) ? 'Forbidden' : res.statusText);
142142
}
143143
const jsonRes = (await res.json());
144144
if (jsonRes.message) {

0 commit comments

Comments
 (0)