exception handling in asp.net webapi code example
Example: exception handling in c# web api
catch (Exception ex)
{
_logger.LogError(ex.ToString());
Response.AddApplicationError(ex.Message);
return StatusCode(500, ex.Message);
}