title: What approach is there for handling and returning errors (non-exceptional and exceptional) in Domain Driven Design entities and aggregate roots?
body: <p>I'm trying to find a good article/examples of how DDD entities treat errors (and what would be considered exceptional errors and what wouldn't) and how they pass them up to the calling application layer (which usually wraps operations in a transaction that would need to be rolled back). </p>
  
  <p>Currently I'm thinking to consider all errors that would break the transaction of an aggregate (such as validation) to be exceptions. This way I can rollback the transaction in a "catch" block. For example:</p>
  
  <p><em>SomeApplicationService:</em></p>
  
  <pre><code>// start transaction here
  // ...
  
  try 
  {
      $user = $userRepository-&gt;userOfId($id);
      $user-&gt;doSomething();
      $user-&gt;doSomethingElse();  // &lt;-- imagine an error thrown here
      $userRepository-&gt;save($user);
  } 
  catch (CustomFriendlyForUIException $e)
  {
      // Custom Friendly for UI error
      // Rollback transaction and add error/message to UI payload DTO
      // ...
  }
  catch (AnotherCustomException $e)
  {
      // Not friendly to UI, so use general error message for UI
      // Rollback transaction and add error/message to UI payload DTO
      // ...
  }
  catch (Exception $e)
  {
      // Catch all other exceptions, use general error message for UI
      // Rollback transaction and add error/message to UI payload DTO
      // ...
  }
  
  // end transaction
  </code></pre>
  
  <p>Is this the correct approach, or am I missing something?</p>