-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Axios 추가 #12
chore: Axios 추가 #12
Conversation
(response) => { | ||
return response; | ||
}, | ||
(error) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: handlerErrorResponse 라는 함수에서 처리하시면 어떨까요?
그리고, 만약에 axios에러에서 response값이 없는 에러가 발생하게 된다면 전체 앱이 뻗을 수도 있을 것 같아요.
옵셔널 체이닝으로 관련 에러 방지 해주시면 좋을 것 같아요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export const handleErrorResponse = (error) => {
if (error instanceof CustomError) {
console.log('CustomError: ', error.name, error.message);
return;
}
console.log('Error: ', error?.message);
};
리뷰 주신 내용으로 handlerErrorResponse 함수 구현해보았습니다.
src/lib/api/article.js
Outdated
} catch (error) { | ||
return { error: error.message }; | ||
throw new Error(error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: 이런느낌으로 에러를 확장해서 쓰실 수 있어요! 추후에 센트리 설계하실때 입맛에 맞게 변경하실 수 있을거에요
class CustomError extends Error {
constructor(message: string) {
super(message);
this.name = 'SomeThing Error';
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CustomError는 추가해보았는데, 아직 센트리를 반영하면서 어떤식으로 변경되는지는 감이 잘 오질 않네요.
센트리를 반영해보면서 더 고민해보도록 하겠습니다! 🙂
리뷰 주신내용 모두 반영하여 Axios PR도 머지하도록 할게요. |
작업 주제
작업 내용(어떤 부분을 리뷰어가 집중해서 봐야할까요?)
feat: 데이터 API 요청 처리 #9 (comment)
관련 Docs
추가 코멘트
체크리스트(PR 올리기 전 아래의 내용을 확인해주세요.)
리뷰 규칙