vendredi 3 février 2017

Handling remote api validation errors in service layer

Imagine that there is a service class that talks to remote service. For example, registering and updating users. Before talking to remote service, our service class doesn't know if submitted data is valid. The question is: how to handle validation errors from remote service? I've thought about it, and have some options:

  • Throw an Exception when validation fails
  • Pass an Errors object that collects validation errors
  • make a method getLastErrors() in a service class

Maybe there are other better solution exist?

Aucun commentaire:

Enregistrer un commentaire