feat: add error handling for undefined results#430
Conversation
📝 WalkthroughWalkthroughArgumentError를 받아 invalidValue를 기반으로 각 도메인별 Changes
Sequence Diagram(s)(생성 조건 미충족 — 생략) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
이 Exception 기준으로 리뷰받고 리뷰된 코드 기준으로 나머지 부분도 작업할게요. |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
lib/app/modules/chat/data/models/kick_user_response_model.dart(2 hunks)lib/app/modules/chat/data/repositories/websocket_pot_action_repository.dart(1 hunks)lib/app/modules/chat/domain/exceptions/kick_user_exception.dart(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- lib/app/modules/chat/data/models/kick_user_response_model.dart
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-10-09T12:08:57.924Z
Learnt from: 2paperstar
Repo: gsainfoteam/pot-g-flutter PR: 144
File: lib/app/modules/chat/data/repositories/websocket_pot_info_repository.dart:140-148
Timestamp: 2025-10-09T12:08:57.924Z
Learning: In `lib/app/modules/chat/data/repositories/websocket_pot_info_repository.dart`, the `accounting` method intentionally uses integer division (`~/`) for `costPerUser` calculation (`amount ~/ (targets.length + 1)`), which may drop the remainder. This is an intentional design decision by the team.
Applied to files:
lib/app/modules/chat/data/repositories/websocket_pot_action_repository.dart
📚 Learning: 2025-11-25T23:55:05.121Z
Learnt from: CR
Repo: gsainfoteam/pot-g-flutter PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T23:55:05.121Z
Learning: Define exception classes as `sealed class` and use `const factory` to define domain layer exceptions
Applied to files:
lib/app/modules/chat/domain/exceptions/kick_user_exception.dart
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Build iOS App and Test
- GitHub Check: Build Android App and Test
🔇 Additional comments (1)
lib/app/modules/chat/domain/exceptions/kick_user_exception.dart (1)
16-17: LGTM! 예외 클래스 구현이 올바릅니다
UnknownJsonValueException구현이 기존 예외 패턴(NetworkErrorException,UnknownException)과 일관성 있게 작성되었습니다:
- sealed class와 const factory 패턴을 올바르게 사용 (코딩 가이드라인에 따름)
toString()메서드가 디버그 모드에서만 상세 정보를 노출하도록 구현- 네이밍이 명확하고 목적을 잘 나타냄
Based on coding guidelines, sealed class with const factory pattern is correctly used.
Also applies to: 65-72
3d43ad0 to
0981540
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
lib/app/modules/chat/data/repositories/websocket_pot_action_repository.dart(1 hunks)lib/app/modules/chat/domain/exceptions/kick_user_exception.dart(2 hunks)lib/app/modules/chat/presentation/extensions/pot_action_exception.dart(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- lib/app/modules/chat/data/repositories/websocket_pot_action_repository.dart
- lib/app/modules/chat/presentation/extensions/pot_action_exception.dart
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-11-25T23:55:05.121Z
Learnt from: CR
Repo: gsainfoteam/pot-g-flutter PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T23:55:05.121Z
Learning: Define exception classes as `sealed class` and use `const factory` to define domain layer exceptions
Applied to files:
lib/app/modules/chat/domain/exceptions/kick_user_exception.dart
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Build iOS App and Test
- GitHub Check: Build Android App and Test
🔇 Additional comments (1)
lib/app/modules/chat/domain/exceptions/kick_user_exception.dart (1)
65-72: 구현 패턴이 기존 예외 클래스들과 일관됩니다.
kDebugMode를 활용한toString()구현,const생성자 사용, sealed class 확장 패턴이NetworkErrorException,UnknownException과 동일하게 잘 적용되었습니다. Based on learnings, sealed class와 const factory 패턴 사용이 적절합니다.
There was a problem hiding this comment.
Actionable comments posted: 6
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (16)
lib/app/modules/chat/data/repositories/rest_report_repository.dart(1 hunks)lib/app/modules/chat/data/repositories/websocket_pot_accounting_repository.dart(2 hunks)lib/app/modules/chat/data/repositories/websocket_pot_action_repository.dart(3 hunks)lib/app/modules/chat/domain/exceptions/accounting_confirm_exception.dart(2 hunks)lib/app/modules/chat/domain/exceptions/accounting_request_exception.dart(2 hunks)lib/app/modules/chat/domain/exceptions/departure_time_exception.dart(2 hunks)lib/app/modules/chat/domain/exceptions/leave_pot_exception.dart(2 hunks)lib/app/modules/chat/domain/exceptions/report_exception.dart(1 hunks)lib/app/modules/chat/presentation/extensions/pot_action_exception.dart(3 hunks)lib/app/modules/chat/presentation/extensions/report_exception_extension.dart(1 hunks)lib/app/modules/create/data/repositories/rest_create_pot_repository.dart(1 hunks)lib/app/modules/create/domain/exceptions/create_pot_exception.dart(2 hunks)lib/app/modules/create/presentation/extensions/create_error.dart(1 hunks)lib/app/modules/list/data/repositories/rest_join_pot_repository.dart(1 hunks)lib/app/modules/list/domain/exceptions/join_pot_exception.dart(2 hunks)lib/app/modules/list/presentation/extensions/join_pot_exception.dart(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- lib/app/modules/chat/presentation/extensions/pot_action_exception.dart
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-11-25T23:55:05.121Z
Learnt from: CR
Repo: gsainfoteam/pot-g-flutter PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T23:55:05.121Z
Learning: Define exception classes as `sealed class` and use `const factory` to define domain layer exceptions
Applied to files:
lib/app/modules/chat/domain/exceptions/leave_pot_exception.dartlib/app/modules/chat/domain/exceptions/accounting_confirm_exception.dartlib/app/modules/chat/domain/exceptions/accounting_request_exception.dart
📚 Learning: 2025-10-09T12:08:57.924Z
Learnt from: 2paperstar
Repo: gsainfoteam/pot-g-flutter PR: 144
File: lib/app/modules/chat/data/repositories/websocket_pot_info_repository.dart:140-148
Timestamp: 2025-10-09T12:08:57.924Z
Learning: In `lib/app/modules/chat/data/repositories/websocket_pot_info_repository.dart`, the `accounting` method intentionally uses integer division (`~/`) for `costPerUser` calculation (`amount ~/ (targets.length + 1)`), which may drop the remainder. This is an intentional design decision by the team.
Applied to files:
lib/app/modules/chat/data/repositories/websocket_pot_accounting_repository.dartlib/app/modules/chat/data/repositories/websocket_pot_action_repository.dart
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Build Android App and Test
- GitHub Check: Build iOS App and Test
🔇 Additional comments (10)
lib/app/modules/chat/domain/exceptions/accounting_confirm_exception.dart (1)
11-13: 새로운UnknownResponseException구조가 올바르게 정의되었습니다.
sealed class패턴과const factory사용이 학습된 코딩 가이드라인을 따르고 있으며,invalidArgument필드와toString구현이 적절합니다.Based on learnings, exception classes should use sealed class with const factory pattern.
Also applies to: 45-51
lib/app/modules/chat/domain/exceptions/accounting_request_exception.dart (1)
19-20: 예외 구조가 일관되게 구현되었습니다.
AccountingRequestException에 추가된unknownResponse팩토리와UnknownResponseException클래스가 다른 예외 타입들과 동일한 패턴을 따르고 있습니다.Also applies to: 77-83
lib/app/modules/chat/domain/exceptions/departure_time_exception.dart (1)
13-14: 예외 처리 구조가 올바르게 추가되었습니다.
DepartureTimeException의unknownResponse팩토리와UnknownResponseException클래스가 프로젝트 전반의 일관된 패턴을 따르고 있습니다.Also applies to: 57-63
lib/app/modules/list/domain/exceptions/join_pot_exception.dart (1)
11-12:JoinPotException의 예외 구조가 일관되게 구현되었습니다.다른 모듈의 예외 타입들과 동일한 패턴으로
unknownResponse가 추가되어 코드베이스 전체의 일관성이 유지됩니다.Also applies to: 42-48
lib/app/modules/list/presentation/extensions/join_pot_exception.dart (1)
17-18: 에러 메시지 매핑이 적절하게 추가되었습니다.
UnknownResponseException케이스가 switch에 올바르게 추가되어errors.unknown으로 라우팅됩니다.lib/app/modules/create/presentation/extensions/create_error.dart (1)
17-18: UnknownResponseException → errors.unknown 매핑 추가 적절함CreatePotException의 새로운
UnknownResponseException케이스를errors.unknown으로 매핑해 다른 도메인과 일관성을 맞추고, 예측 불가능한 응답에 대해 공통 fallback 메시지를 주는 구조가 잘 정리되어 있습니다. 추가 수정 없이 이대로 괜찮아 보입니다.lib/app/modules/chat/presentation/extensions/report_exception_extension.dart (1)
10-10: ReportUnknownResponseException 처리 로직 일관성 좋습니다새
ReportUnknownResponseException을 다른 unknown 계열과 동일하게errors.unknown으로 매핑해서, 도메인 예외 설계와 프레젠테이션 레이어의 에러 메시지 매핑이 자연스럽게 맞춰져 있습니다. 현재 구현으로 충분해 보입니다.lib/app/modules/chat/domain/exceptions/leave_pot_exception.dart (1)
13-14: LeavePotException.unknownResponse 추가 설계가 가이드와 잘 맞습니다
LeavePotException에unknownResponse팩토리와UnknownResponseException클래스를 분리해 둔 덕분에, ArgumentError 기반의 “알 수 없는 응답” 케이스를 도메인 레벨에서 명확하게 구분할 수 있어 좋습니다.sealed 예외 +
const factory패턴을 사용하라는 기존 AGENTS 가이드와도 일치하고,toString에invalidArgument를 포함해 디버깅에도 도움이 되는 구조라 별다른 보완 없이 적절해 보입니다.Also applies to: 50-55
lib/app/modules/create/domain/exceptions/create_pot_exception.dart (1)
11-12: CreatePotException.unknownResponse 도메인 모델링이 명확합니다알 수 없는 응답을
invalidArgument와 함께 표현하는UnknownResponseException을 새로 두고, 이를CreatePotException.unknownResponse팩토리로 노출한 구조가 명확합니다.
- 도메인 예외를
sealed class + const factory로 설계하라는 기존 가이드와 일치하고toString에invalidArgument를 포함해 디버깅 시 어떤 값이 문제였는지 바로 파악할 수 있는 점도 좋습니다.리포지토리 쪽에서만
invalidArgument를 String으로 맞춰 넘겨주면(예:'${e.invalidValue}') 이 설계는 그대로 활용 가능해 보입니다.Also applies to: 34-40
lib/app/modules/chat/domain/exceptions/report_exception.dart (1)
8-11: ReportException.unknownResponse / ReportUnknownResponseException 설계 일관적입니다
ReportException에unknownResponse팩토리와ReportUnknownResponseException을 추가해, 네트워크/알 수 없음 케이스와 동일한 패턴으로 “알 수 없는 응답 + errorId”를 다룰 수 있게 된 점이 좋습니다.
errorId를 필드로 들고 있고withErrorId가 다시ReportException.unknownResponse(invalidArgument, errorId)를 반환하도록 구현되어 있어, 기존ReportNetworkException/ReportUnknownException흐름과 잘 맞습니다.프레젠테이션 레이어의
ReportExceptionX.getErrorMessage와도 자연스럽게 연결될 것으로 보이며, 현재 변경 내용만으로는 추가적인 수정이 필요 없어 보입니다.Also applies to: 18-31
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
lib/app/modules/chat/data/repositories/rest_report_repository.dart (1)
38-39: 과거 리뷰의 타입 안전성 개선이 적용되었습니다. null 처리를 더 명확하게 개선하는 것을 권장합니다.
.toString()을 적용하여 과거 리뷰에서 제기된 타입 안전성 문제를 해결했습니다. 다만invalidValue가 null일 수 있으므로, 이 패턴을 다른 부분에도 적용하기 전에 null-safe 연산자를 사용하는 것을 권장합니다.다음 diff를 적용하여 null 처리를 더 명확하게 개선하세요:
- } on ArgumentError catch (e) { - throw ReportException.unknownResponse(e.invalidValue.toString()); + } on ArgumentError catch (e) { + throw ReportException.unknownResponse( + e.invalidValue?.toString() ?? 'unknown' + );이렇게 하면
invalidValue가 null인 경우 'unknown'이라는 명확한 기본값을 제공하여, "null" 문자열이 아닌 의미 있는 폴백을 사용할 수 있습니다.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
lib/app/modules/chat/data/repositories/rest_report_repository.dart(1 hunks)lib/app/modules/chat/data/repositories/websocket_pot_accounting_repository.dart(2 hunks)lib/app/modules/chat/data/repositories/websocket_pot_action_repository.dart(3 hunks)lib/app/modules/create/data/repositories/rest_create_pot_repository.dart(1 hunks)lib/app/modules/list/data/repositories/rest_join_pot_repository.dart(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- lib/app/modules/create/data/repositories/rest_create_pot_repository.dart
- lib/app/modules/chat/data/repositories/websocket_pot_action_repository.dart
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-09T12:08:57.924Z
Learnt from: 2paperstar
Repo: gsainfoteam/pot-g-flutter PR: 144
File: lib/app/modules/chat/data/repositories/websocket_pot_info_repository.dart:140-148
Timestamp: 2025-10-09T12:08:57.924Z
Learning: In `lib/app/modules/chat/data/repositories/websocket_pot_info_repository.dart`, the `accounting` method intentionally uses integer division (`~/`) for `costPerUser` calculation (`amount ~/ (targets.length + 1)`), which may drop the remainder. This is an intentional design decision by the team.
Applied to files:
lib/app/modules/chat/data/repositories/websocket_pot_accounting_repository.dart
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Build Android App and Test
- GitHub Check: Build iOS App and Test
🔇 Additional comments (3)
lib/app/modules/list/data/repositories/rest_join_pot_repository.dart (1)
32-33: ArgumentError → UnknownResponse 매핑 구현이 타입/도메인 관점에서 적절합니다.
ArgumentError를 별도로 캐치해서JoinPotException.unknownResponse로 변환한 흐름이 PR 목적(정의되지 않은 결과에 대한 에러 처리 추가)과 잘 맞습니다.
e.invalidValue.toString()으로 명시적으로 문자열 변환한 것도 다른 리포지토리들과의 일관성과 타입 안정성 측면에서 적절해 보이며, 추가 수정이 필요한 부분은 없어 보입니다.lib/app/modules/chat/data/repositories/websocket_pot_accounting_repository.dart (2)
62-65: LGTM!이전 리뷰 피드백대로
e.invalidValue.toString()을 사용하여 타입 안전성을 확보했습니다.ArgumentError처리 로직이 적절하게 구현되었습니다.
97-100: LGTM!
confirmAccounting메서드에서도 동일한 패턴으로ArgumentError를 처리하고 있으며,.toString()변환으로 타입 안전성이 확보되었습니다.
Summary by CodeRabbit
버그 수정
사용자 안내
✏️ Tip: You can customize this high-level summary in your review settings.