amosproj / amos2021ss07-bike-nest

MIT License
1 stars 0 forks source link

Exceptions #175

Closed rmandlx closed 3 years ago

rmandlx commented 3 years ago

Implementeda GlobalExceptionHandler for the Backend that can be used to conveniently indicate for the frontend, that an error has happend. Now on frontend side, the fetches will only have to check the status code of a response and if its 200, it will in be the expected format. Elsewise we throw an error in that promise. So basically anyone who uses the service classes can just call .then on the Promises and expect a correct result. Any possible errors should be catched with the .catch function!

rmandlx commented 3 years ago

A nice side effect is, that it will be easier for the developers now to find errors. For example if the backend is not running, the fetch will timeout and in that case a message is logged that tells the user that the backend might not be running. Or if the response from the fetch is 401 unauthorized it will log that down. That way errors can be narrowed down better and we don't have to guess if its a backend or frontend error.