easy c# rest api example on error handling
Example: exception handling in c# web api
catch (Exception ex)
{
_logger.LogError(ex.ToString());
Response.AddApplicationError(ex.Message);
return StatusCode(500, ex.Message);
}