title: Return meaningful errors in API using CQRS pattern
body: <p>When using the Mediatr pattern I find quite challenging to return meaningful errors to an API controller. Let's take the <code>OrdersController.CancelOrder</code> method as an example (<a href="https://github.com/dotnet-architecture/eShopOnContainers/blob/dev/src/Services/Ordering/Ordering.API/Controllers/OrdersController.cs" rel="noreferrer">src</a>).</p>
  
  <p>In this example, they "only" return <code>Ok()</code> and <code>BadRequest()</code>. In that case how will they return errors like "This orderid does not exist" (404) OR "this order has been shipped" (400) (...). </p>
  
  <p>We could introduce a new class called <code>Result</code> holding both the returned values (if any) and potentially error messages. In that case, all your commands, queries should return <code>Result&lt;YourModel&gt;</code>. We could also add the code directly inside the controller. I cannot make up my mind both solutions have pros and cons.</p>
  
  <p>What do you think about that?</p>
  
  <p>Thx
  Seb</p>