-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: 에러 핸들링 리팩토링 #245
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| export interface EventDeletionResponse { | ||
| code: string; | ||
| message: string; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,9 @@ | ||
| export interface HostInvitationRequest { | ||
| email: string; | ||
| } | ||
|
|
||
| export interface HostInvitationResponse { | ||
| code: string; | ||
| message: string; | ||
| result?: string; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,83 +1,79 @@ | ||
| import { useEffect, useRef, useState } from "react"; | ||
| import QrScanner from "qr-scanner"; | ||
| import { useTicketQrCodeValidate } from "../hooks/useOrderHook"; | ||
| import Button from "../../../../design-system/ui/Button"; | ||
| import { useEffect, useRef, useState } from 'react'; | ||
| import QrScanner from 'qr-scanner'; | ||
| import { useTicketQrCodeValidate } from '../hooks/useOrderHook'; | ||
| import Button from '../../../../design-system/ui/Button'; | ||
|
|
||
| const QrScannerComponent = () => { | ||
| const videoRef = useRef<HTMLVideoElement>(null); | ||
| const [isScanning, setIsScanning] = useState(false); | ||
| const qrScannerRef = useRef<QrScanner | null>(null); | ||
| const videoRef = useRef<HTMLVideoElement>(null); | ||
| const [isScanning, setIsScanning] = useState(false); | ||
| const qrScannerRef = useRef<QrScanner | null>(null); | ||
|
|
||
| const { mutate: validateQr } = useTicketQrCodeValidate(); | ||
| const { mutate: validateQr } = useTicketQrCodeValidate(); | ||
|
|
||
| useEffect(() => { | ||
| if (!videoRef.current) return; | ||
| useEffect(() => { | ||
| if (!videoRef.current) return; | ||
|
|
||
| const scanner = new QrScanner( | ||
| videoRef.current, | ||
| (decoded) => { | ||
| const data = decoded.data; | ||
| setIsScanning(false); | ||
| scanner.stop(); | ||
| checkInApiCall(data); | ||
| }, | ||
| { | ||
| onDecodeError: (err) => { | ||
| console.warn("QR decode error:", err); | ||
| }, | ||
| highlightScanRegion: true, | ||
| maxScansPerSecond: 5, | ||
| } | ||
| ); | ||
|
|
||
| qrScannerRef.current = scanner; | ||
| const scanner = new QrScanner( | ||
| videoRef.current, | ||
| decoded => { | ||
| const data = decoded.data; | ||
| setIsScanning(false); | ||
| scanner.stop(); | ||
| checkInApiCall(data); | ||
| }, | ||
| { | ||
| onDecodeError: err => { | ||
| console.warn('QR decode error:', err); | ||
| }, | ||
| highlightScanRegion: true, | ||
| maxScansPerSecond: 5, | ||
| } | ||
| ); | ||
|
|
||
| return () => { | ||
| scanner.destroy(); | ||
| qrScannerRef.current = null; | ||
| }; | ||
| }, []); | ||
| qrScannerRef.current = scanner; | ||
|
|
||
| const handleStartScan = async () => { | ||
| try { | ||
| await navigator.mediaDevices.getUserMedia({ video: true }); | ||
| qrScannerRef.current?.start(); | ||
| setIsScanning(true); | ||
| } catch (e) { | ||
| alert( | ||
| "카메라 접근이 차단되어 있어 스캔할 수 없습니다.\n시스템 설정 또는 브라우저 설정에서 권한을 허용해 주세요." | ||
| ); | ||
| } | ||
| return () => { | ||
| scanner.destroy(); | ||
| qrScannerRef.current = null; | ||
| }; | ||
| }, []); | ||
|
|
||
| const checkInApiCall = async (qrData: string) => { | ||
| try { | ||
| const params = new URLSearchParams(qrData.replace(/-/g, '=')); | ||
| const orderIdStr = params.get('orderId'); | ||
| const sig = params.get('sig'); | ||
| const orderId = orderIdStr ? parseInt(orderIdStr, 10) : NaN; | ||
| const handleStartScan = async () => { | ||
| try { | ||
| await navigator.mediaDevices.getUserMedia({ video: true }); | ||
| qrScannerRef.current?.start(); | ||
| setIsScanning(true); | ||
| } catch { | ||
| alert( | ||
| '카메라 접근이 차단되어 있어 스캔할 수 없습니다.\n시스템 설정 또는 브라우저 설정에서 권한을 허용해 주세요.' | ||
| ); | ||
| } | ||
| }; | ||
|
|
||
| if (!isNaN(orderId) && sig) { | ||
| validateQr({ orderId, sig }); | ||
| } else { | ||
| alert("QR 코드 데이터 형식이 올바르지 않습니다."); | ||
| } | ||
| } catch { | ||
| alert("QR 코드 데이터를 파싱할 수 없습니다."); | ||
| } | ||
| }; | ||
| const checkInApiCall = async (qrData: string) => { | ||
| try { | ||
| const params = new URLSearchParams(qrData.replace(/-/g, '=')); | ||
| const orderIdStr = params.get('orderId'); | ||
| const sig = params.get('sig'); | ||
| const orderId = orderIdStr ? parseInt(orderIdStr, 10) : NaN; | ||
|
|
||
| return ( | ||
| <div className="p-4"> | ||
| <video | ||
| ref={videoRef} | ||
| className="border rounded w-full max-w-md" | ||
| style={{ aspectRatio: "3 / 4" }} | ||
| /> | ||
| {!isScanning && ( | ||
| <Button label="스캔하기" onClick={handleStartScan} className="w-full h-12 rounded-full mt-10 px-4 py-2" /> | ||
| )} | ||
| </div> | ||
| ); | ||
| if (!isNaN(orderId) && sig) { | ||
| validateQr({ orderId, sig }); | ||
| } else { | ||
| alert('QR 코드 데이터 형식이 올바르지 않습니다.'); | ||
| } | ||
| } catch { | ||
| alert('QR 코드 데이터를 파싱할 수 없습니다.'); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <div className="p-4"> | ||
| <video ref={videoRef} className="border rounded w-full max-w-md" style={{ aspectRatio: '3 / 4' }} /> | ||
| {!isScanning && ( | ||
| <Button label="스캔하기" onClick={handleStartScan} className="w-full h-12 rounded-full mt-10 px-4 py-2" /> | ||
| )} | ||
| </div> | ||
| ); | ||
| }; | ||
| export default QrScannerComponent; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
💡 Verification agent
🧩 Analysis chain
특정 에러 코드 처리 로직을 검토해주세요.
에러 응답 구조에 대한 안전한 접근과 특정 에러 코드(
EVENT4002) 처리가 잘 구현되었습니다. 다만 사용자 경험 측면에서alert사용을 토스트나 모달 등의 더 나은 UI 컴포넌트로 대체하는 것을 고려해보세요.다음 스크립트로 다른 에러 코드들도 처리가 필요한지 확인해보세요:
🏁 Script executed:
Length of output: 1054
이벤트 에러 코드 처리 검증 및 UX 개선 제안
EVENT[0-9]+패턴을 검색한 결과, 대응 로직이 필요한 에러 코드는 현재EVENT4002하나뿐입니다.EVENT4002)는src/entities/event/hook/useEventHook.ts(onError 콜백)src/shared/ui/EventCard.tsx(삭제 불가 경고)두 곳에서 일관되게 처리되고 있음을 확인했습니다.
→ 추가 처리해야 할 다른 에러 코드는 없습니다.
다만, 사용자 경험 측면에서
alert호출 대신 토스트(Toast)나 모달(Modal) 같은 비차단 UI 컴포넌트로 교체할 것을 권장드립니다.🤖 Prompt for AI Agents