Error handling (Sending ex.Message to the client)
<p>I have an ASP.NET Core 1.0 Web API application and trying to figure out how to pass the exception message to the client if a function that my controller is calling errors out.</p>

<p>I have tried so many things, but nothing implements <code>IActionResult</code>.</p>

<p>I don't understand why this isn't a common thing that people need. If there truthfully is no solution can someone tell me why?</p>

<p>I do see some documentation out there using <code>HttpResponseException(HttpResponseMessage)</code>, but in order to use this, I have to install the compat shim. Is there a new way of doing these things in Core 1.0?</p>

<p>Here is something I have been trying with the shim but it isn't working:</p>

<pre><code>// GET: api/customers/{id}
[HttpGet("{id}", Name = "GetCustomer")]
public IActionResult GetById(int id)
{
    Customer c = _customersService.GetCustomerById(id);
    if (c == null)
    {
        var response = new HttpResponseMessage(HttpStatusCode.NotFound)
        {
            Content = new StringContent("Customer doesn't exist", System.Text.Encoding.UTF8, "text/plain"),
            StatusCode = HttpStatusCode.NotFound

        };

        throw new HttpResponseException(response);

        //return NotFound();
    }
    return new ObjectResult(c);
}
</code></pre>

<p>When the <code>HttpResponseException</code> is thrown, I look on the client and can't find the message I am sending anything in the content.</p>