tracehubpm / pmo

Project registry, facilities and its home
MIT License
4 stars 0 forks source link

Custom exceptions instead of exception handling #83

Open h1alexbel opened 6 months ago

h1alexbel commented 6 months ago

now we doing something like this:

throw new ResourceAlreadyExistsException(...);

and we do support exception handling via Spring Exception Handlers:

https://github.com/tracehubpm/pmo/blob/385414f0755d33204370b03d4078fc53170bd26a/src/main/java/git/tracehub/pmo/controller/AdviceController.java#L76-L87

We actually can get rid of this by making all our custom exceptions extend HttpStatusException. After this all of them will be handled by Spring

@hizmailovich wdyt?

dukris commented 6 months ago

But for now our custom exceptions are already inherited from ResponseStatusException. Why would it be better to replace it with HttpStatusException? We will still need to handle it in ControllerAdvice...

h1alexbel commented 6 months ago

@hizmailovich If we do inherit HttpStatusException then we can remove Exception Handling inside ControllerAdvice