CouncilDataProject / seattle_v2

Website for interacting with Seattle's instance of CDP
https://councildataproject.github.io/seattle
BSD 3-Clause "New" or "Revised" License
5 stars 6 forks source link

feature/add-error-handling #71

Closed tohuynh closed 4 years ago

tohuynh commented 4 years ago

Pull request recommendations:

The key files are: useDataApi.js is a custom hook to fetch data from the database. I lifted the data fetching logic in all /containers components into this custom hook.

DataApiContainer.jsx is a general wrapper component to render the returned data of an API call. If there was an error from the API call, it will throw an error. Or if data fetching is in progress, it will show the loader. If data fetching succeeded it will show the data. I lifted all conditional rendering logic in /containers components into DataApiContainer.jsx.

GeneralErrorBoundary.jsx is the component to catch errors and display the error message. I use it by wrapping it around a component like so:

<GeneralErrorBoundary>
  <Component/>
</GeneralErrorBoundary>

GeneralErrorBoundary will catch JavaScript errors anywhere in the child component tree and display the fallback UI.

I use GeneralErrorComponent at two 'levels'. One top-level in App.js. And one for each component in /pages.

Thanks for contributing!

evamaxfield commented 4 years ago

Actually I do have a minor request:

Can you make the text:

Please fill out a Github issue so we can address it soon :)

To be:

Sorry about that. To alert us of the issue, please fill out an issue ticket and we will try to fix it as soon as we can.

and make issue ticket link to this repo's github issues?

tohuynh commented 4 years ago

Actually I do have a minor request:

Can you make the text:

Please fill out a Github issue so we can address it soon :)

To be:

Sorry about that. To alert us of the issue, please fill out an issue ticket and we will try to fix it as soon as we can.

and make issue ticket link to this repo's github issues?

Yes issue ticket will link to https://github.com/CouncilDataProject/seattle/issues/new/choose