codestates / codestates/conimals
[정새얀] 220525 Error - Handling
- Dominant language
- JavaScript
- Stars
- 3
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Description
> 해결된 에러라면 라벨에 'Complete' 를 달아주세요.
> 미해결된 에러라면 라벨을 'In progress' 로 변경해주세요.
### 어떤 에러인가요?
- 마이페이지에서 비밀번호 수정하기 컨트롤러 작성 후 포스트맨으로 요청, 응답을 보냈을 때 에러가 뜸.
- 마이페이지 라우트를 만들어 연결할 때 에러가 뜸
### 에러 메시지
```bash
return done(new TokenExpiredError('jwt expired', new Date(payload.exp * 1000)));
^
Token ExpiredError: jwt expired
```
```bash
node:internal/process/promises:246
triggerUncaughtException(err, true /* fromPromise */);
^
AssertionError [ERR_ASSERTION]: Missing where attribute in the options parameter
```
```bash
throw new TypeError('Router.use() requires a middleware function but got a ' + gettype(fn))
^
TypeError: Router.use() requires a middleware function but got a Object
```
### 에러 핸들링 방법
- jwt expired 에러는 access token을 생성할 때 유효 시간을 1시간으로 설정했기 때문에 시간이 지나서 나온 메시지였다.
에러 해결을 위해 일단 유효 시간을 더 길게 늘려주었다.
- 두번째 에러는 보통 오타가 있거나 문법에 맞지 않게 써서 나오는 에러 메시지라고 했다.
sequelize 공식 문서를 참조하여 update의 문법을 봤더니, 중괄호로 제대로 감싸주지 않아서 나오는 에러였다.
- 세번째 에러는 라우트를 만들어 연결할 때 최하단부에 module.exports = router;를 써주지 않아 나오는 에러였다.
작성해주고 저장하니 바로 정상 작동되었다.
### 에러 핸들링을 위해 참고한 레퍼런스 링크
[sequelize update 구문 관련 링크](https://sequelize.org/docs/v6/core-concepts/model-querying-basics/#logical-combinations-with-operators)
[세번째 에러 관련 해결 링크](https://tristan91.tistory.com/529)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.