jtart / react-universal-app

Library for building a single-page application with Universal React component(s) and React Router.
MIT License
14 stars 2 forks source link

Improve the error for unmatched routes #78

Open pjlee11 opened 5 years ago

pjlee11 commented 5 years ago

Improves the error so that the regex is also output with the failing route.

image

coveralls commented 5 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 3a22fd871756744b657683f53505ea0e9ae1ee00 on pjlee11:improve-route-matching-error into f9721d4d5e23c981ba874c43a5608e278dfcb32c on jtart:master.

jtart commented 5 years ago

This could push a highly technical and obscure message to a user. Can you not just wrap the call to loadInitialData in a try-catch block and handle an error message manually yourself? You might want a try-catch block to handle this thrown error anyway (that try-catch block is a bit redundant, I should remove it!).

pjlee11 commented 5 years ago

The main reason I did this was because I found it hard to debug the regex defined in the application compared to the matches it gets once used with react-router-config. The current error is very vague, which makes sense if it is intended for the end user. However, I would have thought the application would want to catch the error before showing it to the user, which would mean that this could give a highly technical message for easier debugging.