[TIL] 230712

김주희·2023년 7월 12일
0

내배캠 9주차 TIL

목록 보기
3/5

오늘의 목표

  1. 개인 프로젝트 진행

▶️ throw문

  • 원래는 service에서 오류 메시지를 던져주고 싶었지만 일단은 throw로 남겨두기로 했다. 튜터님의 피드백을 받아보기로 했는데, throw가 service에서 해결해야 할 일을 controller로 넘겨버리게 되는 것이니 이런 식으로 사용하는 건 비추천한다고 하셨다. 결국 수정쓰.
// 수정 전
if (!nickname || !password || !confirmPassword) {
      const err = new Error('모든 항목을 입력해주셔야 합니다.')
      err.statusCode = 400;
      throw err;
}

// 수정 후 : service
if (!nickname || !password || !confirmPassword) {
      return {
        status: 400,
        message: '모든 항목을 입력해주셔야 합니다.',
      };
}

// 수정 후 : controller
const { status, message } = await this.userService.signupUser(
      nickname,
      password,
      confirmPassword
);

    return res.status(status).json(message);

▶️ git commit 오류

  • git commit을 하면 커밋 메시지를 제목과 본문으로 쓸 수 있기 때문에 쓰려고 하는데 오류가 떴다. 오류 내용은 이전에 git commit을 완료하지 않고 터미널 창을 껐기 때문에 git commit으로 하던 작업이 완료 되지 않아 해결하라는 오류였다.
Swap file "~/Desktop/Nodejs/Week9/PROJECT_Blog_LV5/.git/.COMMIT_EDITMSG.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:
  • 여기서 D를 입력하면 끝! 다시 git commit을 할 수 있다.
profile
꾸준히 하자

0개의 댓글