Commit bf260acd authored by Paul Kaplan's avatar Paul Kaplan

Catch error from user who is already part of studio

parent cb7c60e8
...@@ -8,13 +8,20 @@ import {selectStudioId, setRoles} from '../../../redux/studio'; ...@@ -8,13 +8,20 @@ import {selectStudioId, setRoles} from '../../../redux/studio';
const Errors = keyMirror({ const Errors = keyMirror({
NETWORK: null, NETWORK: null,
SERVER: null, SERVER: null,
PERMISSION: null PERMISSION: null,
DUPLICATE: null
}); });
const normalizeError = (err, body, res) => { const normalizeError = (err, body, res) => {
if (err) return Errors.NETWORK; if (err) return Errors.NETWORK;
if (res.statusCode === 401 || res.statusCode === 403) return Errors.PERMISSION; if (res.statusCode === 401 || res.statusCode === 403) return Errors.PERMISSION;
if (res.statusCode !== 200) return Errors.SERVER; if (res.statusCode !== 200) return Errors.SERVER;
if (body && body.status === 'error') {
if (body.message.indexOf('already a curator') !== -1) {
return Errors.DUPLICATE;
}
return Errors.UNHANDLED;
}
return null; return null;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment