title: what is preferred approach to return business validation results in business layer
body: <p>Let's assume we have a client application (either web or standalone) which uses kind of business layer (EJB, Spring services etc). Let's say user wants to execute some business logic (e.g. create something). This operation has some preconditions like data format, existing of other objects in DB, permissions etc. Now what is the best design of this business logic layer, I mean how to return validation errors, indicate success, return unexpected error etc?</p>
  
  <p>Ways I know:</p>
  
  <p>1) </p>
  
  <p>for validation errors return e.g. OperationResult object having status and list of violations, </p>
  
  <p>for success: OperationResult with status=success and empty errors list, </p>
  
  <p>for unexpected errors throw runtime exception</p>
  
  <p>2) </p>
  
  <p>for validation errors throw ValidationException (runitme or checked?) having list of violations</p>
  
  <p>for success: void or created entity if required</p>
  
  <p>for unexpected errors throw runtime exception</p>
  
  <p>There are two basic ways I know but every time I start writing I have hard time to get it right.</p>