Open LKASTI opened 3 months ago
Researching how to accomplish this through the following resources:
https://www.baeldung.com/spring-response-entity https://www.baeldung.com/exception-handling-for-rest-with-spring https://www.baeldung.com/global-error-handler-in-a-spring-rest-api
This seems like a good way to handle exceptions: https://www.baeldung.com/spring-response-status-exception.
For example, we create a custom exception class that inherits from Exception. Then we can run try catch blocks in the service and controller to return a detailed exception similar to this:
I looked into something like this, but the only concern I have is that throwing an exception might halt the execution of any code that may come after. For example, in the PageScraper, if the processing of one event throws an exception, I believe the whole scraping process stops. I am not sure if the PageScraper would ever cause an exception to be thrown though.
Now that I think about it, though, I suppose we could just modify the PageScraper to also catch the [Entity]NotFound exception as well.
We need a way to return custom JSON error messages from methods without changing their return type. This should be help the frontend identify errors like appointment conflicts.