mercredi 17 juillet 2019

Recommendation for design of Exception classes skeleton for different Entities

In one of our Java Web module, we have an entity called EntityA and various CRUD operations on this entity throws exceptions like below

  • EntityAException extends IOException
  • EntityANotFoundException extends EntityAException
  • EntityAUnauthorisedException extends EntityAException
  • EntityABadRequestException extends EntityAException
  • EntityABadGatewayException extends EntityAException

Now, we want to add more entities to our module like EntityB, EntityC etc. So seeking recommendations whether to create similar exception classes for each entity for cleaner interface or there can be better way by of doing it in a generic way to avoid multiple classes.

Aucun commentaire:

Enregistrer un commentaire