react-admin: Uncaught exception handling http error
We are working on a client for parse server, which displays some funny behavior around permissions. When an unauthenticated client attempts to list a class to which it doesn’t have access, the parse server returns 400 BAD REQUEST, with the content: {code: 119, error: "Permission denied for action find on class _User."}
This results in the following error on the client:
uncaught at handleFetch TypeError: Cannot read property 'map' of undefined
at http://localhost:3000/static/js/bundle.js:45169:37
at combination (http://localhost:3000/static/js/bundle.js:38863:30)
at combination (http://localhost:3000/static/js/bundle.js:38863:30)
at combination (http://localhost:3000/static/js/bundle.js:38863:30)
at combination (http://localhost:3000/static/js/bundle.js:38863:30)
at dispatch (http://localhost:3000/static/js/bundle.js:38323:23)
at http://localhost:3000/static/js/bundle.js:44782:23
at http://localhost:3000/static/js/bundle.js:43289:19
at dispatch (http://localhost:3000/static/js/bundle.js:39018:19)
at sagaDispatch (http://localhost:3000/static/js/bundle.js:42335:13)
We tried catching this in our HttpClient and disguising it as a 401, thus:
if (status === 400) {
console.log('Got 400. ugh.');
if (json && json.code === 119) {
console.log(json);
console.log('Trying to make it look like a 401');
return Promise.reject(new HttpError('401 UNAUTHORIZED', 401));
}
}
but we still get the same error as above. What’s the correct way to indicate http errors?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 17 (7 by maintainers)
Mind letting the rest of us know what was wrong?