message: API: Refactor DuplicationController 404 handling
diff: @@ -55,9 +55,7 @@ export class DuplicationController {
  @BodyParam('courseAdmin', {required: false}) newCourseAdminId: string,
  @CurrentUser() currentUser: IUser) {
  const courseModel: ICourseModel = await Course.findById(id);
  - if (!courseModel) {
  - throw new NotFoundError();
  - }
  + if (!courseModel) { throw new NotFoundError(); }
  await DuplicationController.assertUserDuplicationAuthorization(currentUser, courseModel);
  // Set the currentUser's id as newCourseAdminId if it wasn't specified by the request.
  @@ -93,14 +91,10 @@ export class DuplicationController {
  @BodyParam('courseId', {required: true}) targetCourseId: string,
  @CurrentUser() currentUser: IUser) {
  const course = await Course.findOne({lectures: id});
  - if (!course) {
  - throw new NotFoundError();
  - }
  + if (!course) { throw new NotFoundError(); }
  await DuplicationController.assertUserDuplicationAuthorization(currentUser, course);
  const targetCourse = await Course.findById(targetCourseId);
  - if (!targetCourse) {
  - throw new NotFoundError(errorCodes.duplication.targetNotFound.text);
  - }
  + if (!targetCourse) { throw new NotFoundError(errorCodes.duplication.targetNotFound.text); }
  await DuplicationController.assertUserDuplicationAuthorization(currentUser, targetCourse);
  const lectureModel: ILectureModel = await Lecture.findById(id);
  @@ -133,15 +127,11 @@ export class DuplicationController {
  @BodyParam('lectureId', {required: true}) targetLectureId: string,
  @CurrentUser() currentUser: IUser) {
  const unitModel: IUnitModel = await Unit.findById(id);
  - if (!unitModel) {
  - throw new NotFoundError();
  - }
  + if (!unitModel) { throw new NotFoundError(); }
  const course = await Course.findById(unitModel._course);
  await DuplicationController.assertUserDuplicationAuthorization(currentUser, course);
  const targetCourse = await Course.findOne({lectures: targetLectureId});
  - if (!targetCourse) {
  - throw new NotFoundError(errorCodes.duplication.targetNotFound.text);
  - }
  + if (!targetCourse) { throw new NotFoundError(errorCodes.duplication.targetNotFound.text); }
  await DuplicationController.assertUserDuplicationAuthorization(currentUser, targetCourse);
  const targetCourseId = extractSingleMongoId(targetCourse);
  