public IHttpActionResult GetStudentsInCourse(int id) { try { List <StudentDTO> students = _service.GetStudentsInCourse(id); // this may throw a not found exception return(Ok(students)); } catch (CourseNotFoundException) { throw new HttpResponseException(HttpStatusCode.NotFound); } }