exception handling in c# web api 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);
}