RSCodingClub / STUCO-Backend

MIT License
3 stars 0 forks source link

Better error handling. #59

Open itotallyrock opened 7 years ago

itotallyrock commented 7 years ago

The current error handling is good in some regards but nonexistent in others. It would be best to reduce redundant code to just have better error handling. We can use built in features to catch errors and handle them gracefully. Like setting up an express middleware to handle unknown error and just sending minimum information in terms of what failed (No need to reduce security by telling the client anything it doesn't need to know). We also would want to handle whole application errors with process.on and gracefully stop the program making sure to close any existing connections, allowing the service to reboot. Furthermore better error handling means catching any and all errors. If something could potentially throw an error during runtime we will need to catch it and prevent full application errors. Like should the database shutdown the whole server shouldn't crash as well it should simply respond with database down errors or simply the database contents don't exist.