From fdcf1b7cffa6c7a5d7a9bf0098a860b02f19ccee Mon Sep 17 00:00:00 2001 From: tkjftkjf Date: Fri, 28 Nov 2025 18:45:15 +0900 Subject: [PATCH 01/13] feat: add error handling for undefined results --- .../chat/data/models/kick_user_response_model.dart | 7 +++++-- .../repositories/websocket_pot_action_repository.dart | 2 ++ .../chat/domain/exceptions/kick_user_exception.dart | 8 ++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/app/modules/chat/data/models/kick_user_response_model.dart b/lib/app/modules/chat/data/models/kick_user_response_model.dart index d82b2833..05283f8b 100644 --- a/lib/app/modules/chat/data/models/kick_user_response_model.dart +++ b/lib/app/modules/chat/data/models/kick_user_response_model.dart @@ -5,8 +5,10 @@ part 'kick_user_response_model.g.dart'; @Freezed(toJson: false) sealed class KickUserResponseModel with _$KickUserResponseModel { - const factory KickUserResponseModel({required KickUserResult result}) = - _KickUserResponseModel; + const factory KickUserResponseModel({ + @JsonKey(unknownEnumValue: KickUserResult.unknown) + required KickUserResult result, + }) = _KickUserResponseModel; factory KickUserResponseModel.fromJson(Map json) => _$KickUserResponseModelFromJson(json); @@ -23,4 +25,5 @@ enum KickUserResult { notYetPaymentConfirmed, potNotExist, potAlreadyClosed, + unknown, } diff --git a/lib/app/modules/chat/data/repositories/websocket_pot_action_repository.dart b/lib/app/modules/chat/data/repositories/websocket_pot_action_repository.dart index 97e02889..ac6a0f72 100644 --- a/lib/app/modules/chat/data/repositories/websocket_pot_action_repository.dart +++ b/lib/app/modules/chat/data/repositories/websocket_pot_action_repository.dart @@ -69,6 +69,8 @@ class WebsocketPotActionRepository implements PotActionRepository { throw KickUserException.potNotExist(); case KickUserResult.potAlreadyClosed: throw KickUserException.potAlreadyClosed(); + case KickUserResult.unknown: + throw KickUserException.unknownJsonValue(); } } on DioException catch (e) { throw KickUserException.networkError(e.message ?? e.error.toString()); diff --git a/lib/app/modules/chat/domain/exceptions/kick_user_exception.dart b/lib/app/modules/chat/domain/exceptions/kick_user_exception.dart index 6a10f6bb..7295096d 100644 --- a/lib/app/modules/chat/domain/exceptions/kick_user_exception.dart +++ b/lib/app/modules/chat/domain/exceptions/kick_user_exception.dart @@ -13,6 +13,8 @@ sealed class KickUserException implements Exception { const factory KickUserException.potNotExist() = PotNotExistException; const factory KickUserException.potAlreadyClosed() = PotAlreadyClosedException; + const factory KickUserException.unknownJsonValue() = + UnknownJsonValueException; const factory KickUserException.networkError(String error) = NetworkErrorException; const factory KickUserException.unknown(Object error) = UnknownException; @@ -60,6 +62,12 @@ class PotAlreadyClosedException extends KickUserException { String toString() => 'KickUserException.PotAlreadyClosedException'; } +class UnknownJsonValueException extends KickUserException { + const UnknownJsonValueException(); + @override + String toString() => 'KickUserException.UnknownJsonValueException'; +} + class NetworkErrorException extends KickUserException { final String error; const NetworkErrorException(this.error); From 13576041a7eb704170e2a1ececcd73980ccbb9f5 Mon Sep 17 00:00:00 2001 From: tkjftkjf Date: Fri, 28 Nov 2025 18:54:25 +0900 Subject: [PATCH 02/13] fix: add new case for KickUserExceptionX --- .../chat/presentation/extensions/pot_action_exception.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/app/modules/chat/presentation/extensions/pot_action_exception.dart b/lib/app/modules/chat/presentation/extensions/pot_action_exception.dart index b4a55e3f..3aef6e6a 100644 --- a/lib/app/modules/chat/presentation/extensions/pot_action_exception.dart +++ b/lib/app/modules/chat/presentation/extensions/pot_action_exception.dart @@ -47,6 +47,8 @@ extension KickUserExceptionX on kick.KickUserException { return errors.pot_not_exist; case kick.PotAlreadyClosedException(): return errors.pot_already_closed; + case kick.UnknownJsonValueException(): + return errors.unknown; case kick.NetworkErrorException(): return errors.network_error; case kick.UnknownException(): From 54f4a043bd2eac4ce43d0bfa4f2dab1ac5c54b87 Mon Sep 17 00:00:00 2001 From: tkjftkjf Date: Fri, 28 Nov 2025 23:05:33 +0900 Subject: [PATCH 03/13] feat: add response value tracking for unknown response --- .../chat/data/models/kick_user_response_model.dart | 3 ++- .../repositories/websocket_pot_action_repository.dart | 2 +- .../chat/domain/exceptions/kick_user_exception.dart | 9 ++++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/app/modules/chat/data/models/kick_user_response_model.dart b/lib/app/modules/chat/data/models/kick_user_response_model.dart index 05283f8b..d4d06dd9 100644 --- a/lib/app/modules/chat/data/models/kick_user_response_model.dart +++ b/lib/app/modules/chat/data/models/kick_user_response_model.dart @@ -8,10 +8,11 @@ sealed class KickUserResponseModel with _$KickUserResponseModel { const factory KickUserResponseModel({ @JsonKey(unknownEnumValue: KickUserResult.unknown) required KickUserResult result, + @JsonKey(name: "value", defaultValue: null) String? value, }) = _KickUserResponseModel; factory KickUserResponseModel.fromJson(Map json) => - _$KickUserResponseModelFromJson(json); + _$KickUserResponseModelFromJson({...json, "value": json["value"]}); } @JsonEnum(fieldRename: FieldRename.pascal) diff --git a/lib/app/modules/chat/data/repositories/websocket_pot_action_repository.dart b/lib/app/modules/chat/data/repositories/websocket_pot_action_repository.dart index ac6a0f72..db0fee09 100644 --- a/lib/app/modules/chat/data/repositories/websocket_pot_action_repository.dart +++ b/lib/app/modules/chat/data/repositories/websocket_pot_action_repository.dart @@ -70,7 +70,7 @@ class WebsocketPotActionRepository implements PotActionRepository { case KickUserResult.potAlreadyClosed: throw KickUserException.potAlreadyClosed(); case KickUserResult.unknown: - throw KickUserException.unknownJsonValue(); + throw KickUserException.unknownJsonValue(result.value!); } } on DioException catch (e) { throw KickUserException.networkError(e.message ?? e.error.toString()); diff --git a/lib/app/modules/chat/domain/exceptions/kick_user_exception.dart b/lib/app/modules/chat/domain/exceptions/kick_user_exception.dart index 7295096d..ef161d87 100644 --- a/lib/app/modules/chat/domain/exceptions/kick_user_exception.dart +++ b/lib/app/modules/chat/domain/exceptions/kick_user_exception.dart @@ -13,7 +13,7 @@ sealed class KickUserException implements Exception { const factory KickUserException.potNotExist() = PotNotExistException; const factory KickUserException.potAlreadyClosed() = PotAlreadyClosedException; - const factory KickUserException.unknownJsonValue() = + const factory KickUserException.unknownJsonValue(String unknownValue) = UnknownJsonValueException; const factory KickUserException.networkError(String error) = NetworkErrorException; @@ -63,9 +63,12 @@ class PotAlreadyClosedException extends KickUserException { } class UnknownJsonValueException extends KickUserException { - const UnknownJsonValueException(); + final String unknownValue; + const UnknownJsonValueException(this.unknownValue); @override - String toString() => 'KickUserException.UnknownJsonValueException'; + String toString() => kDebugMode + ? 'KickUserException.UnknownJsonValueException(error: $unknownValue)' + : 'KickUserException.UnknownJsonValueException'; } class NetworkErrorException extends KickUserException { From 407b3f4d68975f124c095f0440edc75e8255199d Mon Sep 17 00:00:00 2001 From: tkjftkjf Date: Fri, 28 Nov 2025 23:09:15 +0900 Subject: [PATCH 04/13] typo: fix typo --- lib/app/modules/chat/data/models/kick_user_response_model.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/app/modules/chat/data/models/kick_user_response_model.dart b/lib/app/modules/chat/data/models/kick_user_response_model.dart index d4d06dd9..4468c054 100644 --- a/lib/app/modules/chat/data/models/kick_user_response_model.dart +++ b/lib/app/modules/chat/data/models/kick_user_response_model.dart @@ -12,7 +12,7 @@ sealed class KickUserResponseModel with _$KickUserResponseModel { }) = _KickUserResponseModel; factory KickUserResponseModel.fromJson(Map json) => - _$KickUserResponseModelFromJson({...json, "value": json["value"]}); + _$KickUserResponseModelFromJson({...json, "value": json["result"]}); } @JsonEnum(fieldRename: FieldRename.pascal) From 7a6d62c764f41a6b1913a6da4b114caff332959b Mon Sep 17 00:00:00 2001 From: tkjftkjf Date: Sun, 30 Nov 2025 11:29:32 +0900 Subject: [PATCH 05/13] revert: revert to original code --- .../chat/data/models/kick_user_response_model.dart | 10 +++------- .../repositories/websocket_pot_action_repository.dart | 2 -- .../chat/domain/exceptions/kick_user_exception.dart | 11 ----------- .../presentation/extensions/pot_action_exception.dart | 2 -- 4 files changed, 3 insertions(+), 22 deletions(-) diff --git a/lib/app/modules/chat/data/models/kick_user_response_model.dart b/lib/app/modules/chat/data/models/kick_user_response_model.dart index 4468c054..d82b2833 100644 --- a/lib/app/modules/chat/data/models/kick_user_response_model.dart +++ b/lib/app/modules/chat/data/models/kick_user_response_model.dart @@ -5,14 +5,11 @@ part 'kick_user_response_model.g.dart'; @Freezed(toJson: false) sealed class KickUserResponseModel with _$KickUserResponseModel { - const factory KickUserResponseModel({ - @JsonKey(unknownEnumValue: KickUserResult.unknown) - required KickUserResult result, - @JsonKey(name: "value", defaultValue: null) String? value, - }) = _KickUserResponseModel; + const factory KickUserResponseModel({required KickUserResult result}) = + _KickUserResponseModel; factory KickUserResponseModel.fromJson(Map json) => - _$KickUserResponseModelFromJson({...json, "value": json["result"]}); + _$KickUserResponseModelFromJson(json); } @JsonEnum(fieldRename: FieldRename.pascal) @@ -26,5 +23,4 @@ enum KickUserResult { notYetPaymentConfirmed, potNotExist, potAlreadyClosed, - unknown, } diff --git a/lib/app/modules/chat/data/repositories/websocket_pot_action_repository.dart b/lib/app/modules/chat/data/repositories/websocket_pot_action_repository.dart index db0fee09..97e02889 100644 --- a/lib/app/modules/chat/data/repositories/websocket_pot_action_repository.dart +++ b/lib/app/modules/chat/data/repositories/websocket_pot_action_repository.dart @@ -69,8 +69,6 @@ class WebsocketPotActionRepository implements PotActionRepository { throw KickUserException.potNotExist(); case KickUserResult.potAlreadyClosed: throw KickUserException.potAlreadyClosed(); - case KickUserResult.unknown: - throw KickUserException.unknownJsonValue(result.value!); } } on DioException catch (e) { throw KickUserException.networkError(e.message ?? e.error.toString()); diff --git a/lib/app/modules/chat/domain/exceptions/kick_user_exception.dart b/lib/app/modules/chat/domain/exceptions/kick_user_exception.dart index ef161d87..6a10f6bb 100644 --- a/lib/app/modules/chat/domain/exceptions/kick_user_exception.dart +++ b/lib/app/modules/chat/domain/exceptions/kick_user_exception.dart @@ -13,8 +13,6 @@ sealed class KickUserException implements Exception { const factory KickUserException.potNotExist() = PotNotExistException; const factory KickUserException.potAlreadyClosed() = PotAlreadyClosedException; - const factory KickUserException.unknownJsonValue(String unknownValue) = - UnknownJsonValueException; const factory KickUserException.networkError(String error) = NetworkErrorException; const factory KickUserException.unknown(Object error) = UnknownException; @@ -62,15 +60,6 @@ class PotAlreadyClosedException extends KickUserException { String toString() => 'KickUserException.PotAlreadyClosedException'; } -class UnknownJsonValueException extends KickUserException { - final String unknownValue; - const UnknownJsonValueException(this.unknownValue); - @override - String toString() => kDebugMode - ? 'KickUserException.UnknownJsonValueException(error: $unknownValue)' - : 'KickUserException.UnknownJsonValueException'; -} - class NetworkErrorException extends KickUserException { final String error; const NetworkErrorException(this.error); diff --git a/lib/app/modules/chat/presentation/extensions/pot_action_exception.dart b/lib/app/modules/chat/presentation/extensions/pot_action_exception.dart index 3aef6e6a..b4a55e3f 100644 --- a/lib/app/modules/chat/presentation/extensions/pot_action_exception.dart +++ b/lib/app/modules/chat/presentation/extensions/pot_action_exception.dart @@ -47,8 +47,6 @@ extension KickUserExceptionX on kick.KickUserException { return errors.pot_not_exist; case kick.PotAlreadyClosedException(): return errors.pot_already_closed; - case kick.UnknownJsonValueException(): - return errors.unknown; case kick.NetworkErrorException(): return errors.network_error; case kick.UnknownException(): From 0981540c150e98c98dfde408f3d8bc8905d02a06 Mon Sep 17 00:00:00 2001 From: tkjftkjf Date: Sun, 30 Nov 2025 11:50:30 +0900 Subject: [PATCH 06/13] feat: change error handling method from by using enum to using ArgumentError --- .../repositories/websocket_pot_action_repository.dart | 2 ++ .../chat/domain/exceptions/kick_user_exception.dart | 11 +++++++++++ .../presentation/extensions/pot_action_exception.dart | 2 ++ 3 files changed, 15 insertions(+) diff --git a/lib/app/modules/chat/data/repositories/websocket_pot_action_repository.dart b/lib/app/modules/chat/data/repositories/websocket_pot_action_repository.dart index 97e02889..1d167daa 100644 --- a/lib/app/modules/chat/data/repositories/websocket_pot_action_repository.dart +++ b/lib/app/modules/chat/data/repositories/websocket_pot_action_repository.dart @@ -72,6 +72,8 @@ class WebsocketPotActionRepository implements PotActionRepository { } } on DioException catch (e) { throw KickUserException.networkError(e.message ?? e.error.toString()); + } on ArgumentError catch (e) { + throw KickUserException.unknownResponse(e.message ?? e.toString()); } } diff --git a/lib/app/modules/chat/domain/exceptions/kick_user_exception.dart b/lib/app/modules/chat/domain/exceptions/kick_user_exception.dart index 6a10f6bb..1c593d42 100644 --- a/lib/app/modules/chat/domain/exceptions/kick_user_exception.dart +++ b/lib/app/modules/chat/domain/exceptions/kick_user_exception.dart @@ -13,6 +13,8 @@ sealed class KickUserException implements Exception { const factory KickUserException.potNotExist() = PotNotExistException; const factory KickUserException.potAlreadyClosed() = PotAlreadyClosedException; + const factory KickUserException.unknownResponse(String error) = + UnknownResponseException; const factory KickUserException.networkError(String error) = NetworkErrorException; const factory KickUserException.unknown(Object error) = UnknownException; @@ -60,6 +62,15 @@ class PotAlreadyClosedException extends KickUserException { String toString() => 'KickUserException.PotAlreadyClosedException'; } +class UnknownResponseException extends KickUserException { + final Object error; + const UnknownResponseException(this.error); + @override + String toString() => kDebugMode + ? 'KickUserException.UnknownResponseException(error: $error)' + : 'KickUserException.UnknownResponseException'; +} + class NetworkErrorException extends KickUserException { final String error; const NetworkErrorException(this.error); diff --git a/lib/app/modules/chat/presentation/extensions/pot_action_exception.dart b/lib/app/modules/chat/presentation/extensions/pot_action_exception.dart index b4a55e3f..d4af310f 100644 --- a/lib/app/modules/chat/presentation/extensions/pot_action_exception.dart +++ b/lib/app/modules/chat/presentation/extensions/pot_action_exception.dart @@ -47,6 +47,8 @@ extension KickUserExceptionX on kick.KickUserException { return errors.pot_not_exist; case kick.PotAlreadyClosedException(): return errors.pot_already_closed; + case kick.UnknownResponseException(): + return errors.unknown; case kick.NetworkErrorException(): return errors.network_error; case kick.UnknownException(): From 34753ec1143491ff90b82a789db046c46a21c852 Mon Sep 17 00:00:00 2001 From: tkjftkjf Date: Sun, 30 Nov 2025 11:56:22 +0900 Subject: [PATCH 07/13] fix: fix unmatched type --- lib/app/modules/chat/domain/exceptions/kick_user_exception.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/app/modules/chat/domain/exceptions/kick_user_exception.dart b/lib/app/modules/chat/domain/exceptions/kick_user_exception.dart index 1c593d42..73bc78c0 100644 --- a/lib/app/modules/chat/domain/exceptions/kick_user_exception.dart +++ b/lib/app/modules/chat/domain/exceptions/kick_user_exception.dart @@ -13,7 +13,7 @@ sealed class KickUserException implements Exception { const factory KickUserException.potNotExist() = PotNotExistException; const factory KickUserException.potAlreadyClosed() = PotAlreadyClosedException; - const factory KickUserException.unknownResponse(String error) = + const factory KickUserException.unknownResponse(Object error) = UnknownResponseException; const factory KickUserException.networkError(String error) = NetworkErrorException; From 102c0a07453965e5da68a226a5b55752a8f1c142 Mon Sep 17 00:00:00 2001 From: tkjftkjf Date: Sun, 30 Nov 2025 13:35:31 +0900 Subject: [PATCH 08/13] feat: make error log always show invalid argument --- .../repositories/websocket_pot_action_repository.dart | 2 +- .../chat/domain/exceptions/kick_user_exception.dart | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/app/modules/chat/data/repositories/websocket_pot_action_repository.dart b/lib/app/modules/chat/data/repositories/websocket_pot_action_repository.dart index 1d167daa..5213199d 100644 --- a/lib/app/modules/chat/data/repositories/websocket_pot_action_repository.dart +++ b/lib/app/modules/chat/data/repositories/websocket_pot_action_repository.dart @@ -73,7 +73,7 @@ class WebsocketPotActionRepository implements PotActionRepository { } on DioException catch (e) { throw KickUserException.networkError(e.message ?? e.error.toString()); } on ArgumentError catch (e) { - throw KickUserException.unknownResponse(e.message ?? e.toString()); + throw KickUserException.unknownResponse(e.invalidValue); } } diff --git a/lib/app/modules/chat/domain/exceptions/kick_user_exception.dart b/lib/app/modules/chat/domain/exceptions/kick_user_exception.dart index 73bc78c0..d0d18f24 100644 --- a/lib/app/modules/chat/domain/exceptions/kick_user_exception.dart +++ b/lib/app/modules/chat/domain/exceptions/kick_user_exception.dart @@ -13,7 +13,7 @@ sealed class KickUserException implements Exception { const factory KickUserException.potNotExist() = PotNotExistException; const factory KickUserException.potAlreadyClosed() = PotAlreadyClosedException; - const factory KickUserException.unknownResponse(Object error) = + const factory KickUserException.unknownResponse(String invalidArgument) = UnknownResponseException; const factory KickUserException.networkError(String error) = NetworkErrorException; @@ -63,12 +63,11 @@ class PotAlreadyClosedException extends KickUserException { } class UnknownResponseException extends KickUserException { - final Object error; - const UnknownResponseException(this.error); + final String invalidArgument; + const UnknownResponseException(this.invalidArgument); @override - String toString() => kDebugMode - ? 'KickUserException.UnknownResponseException(error: $error)' - : 'KickUserException.UnknownResponseException'; + String toString() => + 'KickUserException.UnknownResponseException(invalid argument: $invalidArgument)'; } class NetworkErrorException extends KickUserException { From d2a66fa13db252e4fc1dab279d9c5b43cd1c4860 Mon Sep 17 00:00:00 2001 From: tkjftkjf Date: Sun, 30 Nov 2025 14:09:40 +0900 Subject: [PATCH 09/13] feat: implement error handling on domain exceptions --- .../accounting_confirm_exception.dart | 12 +++++++++++- .../accounting_request_exception.dart | 11 ++++++++++- .../exceptions/departure_time_exception.dart | 10 ++++++++++ .../exceptions/leave_pot_exception.dart | 9 +++++++++ .../domain/exceptions/report_exception.dart | 19 +++++++++++++++++++ .../exceptions/create_pot_exception.dart | 10 ++++++++++ .../domain/exceptions/join_pot_exception.dart | 10 ++++++++++ 7 files changed, 79 insertions(+), 2 deletions(-) diff --git a/lib/app/modules/chat/domain/exceptions/accounting_confirm_exception.dart b/lib/app/modules/chat/domain/exceptions/accounting_confirm_exception.dart index 5ddf8551..738ab9a2 100644 --- a/lib/app/modules/chat/domain/exceptions/accounting_confirm_exception.dart +++ b/lib/app/modules/chat/domain/exceptions/accounting_confirm_exception.dart @@ -8,7 +8,9 @@ sealed class AccountingConfirmException implements Exception { const factory AccountingConfirmException.potNotExist() = PotNotExistException; const factory AccountingConfirmException.potAlreadyClosed() = PotAlreadyClosedException; - + const factory AccountingConfirmException.unknownResponse( + String invalidArgument, + ) = UnknownResponseException; const factory AccountingConfirmException.networkError(String error) = NetworkErrorException; const factory AccountingConfirmException.unknown(Object error) = @@ -40,6 +42,14 @@ class PotAlreadyClosedException extends AccountingConfirmException { String toString() => 'AccountingConfirmException.PotAlreadyClosedException'; } +class UnknownResponseException extends AccountingConfirmException { + final String invalidArgument; + const UnknownResponseException(this.invalidArgument); + @override + String toString() => + 'AccountingConfirmException.UnknownResponseException(invalidArgument: $invalidArgument)'; +} + class NetworkErrorException extends AccountingConfirmException { final String error; const NetworkErrorException(this.error); diff --git a/lib/app/modules/chat/domain/exceptions/accounting_request_exception.dart b/lib/app/modules/chat/domain/exceptions/accounting_request_exception.dart index 1360f9b1..7ba19b40 100644 --- a/lib/app/modules/chat/domain/exceptions/accounting_request_exception.dart +++ b/lib/app/modules/chat/domain/exceptions/accounting_request_exception.dart @@ -16,7 +16,8 @@ sealed class AccountingRequestException implements Exception { const factory AccountingRequestException.potNotExist() = PotNotExistException; const factory AccountingRequestException.potAlreadyClosed() = PotAlreadyClosedException; - + const factory AccountingRequestException.unknownResponse(String invalidArgument) = + UnknownResponseException; const factory AccountingRequestException.networkError(String error) = NetworkErrorException; const factory AccountingRequestException.unknown(Object error) = @@ -73,6 +74,14 @@ class PotAlreadyClosedException extends AccountingRequestException { String toString() => 'AccountingRequestException.PotAlreadyClosedException'; } +class UnknownResponseException extends AccountingRequestException { + final String invalidArgument; + const UnknownResponseException(this.invalidArgument); + @override + String toString() => + 'AccountingRequestException.UnknownResponseException(invalidArgument: $invalidArgument)'; +} + class NetworkErrorException extends AccountingRequestException { final String error; const NetworkErrorException(this.error); diff --git a/lib/app/modules/chat/domain/exceptions/departure_time_exception.dart b/lib/app/modules/chat/domain/exceptions/departure_time_exception.dart index ebe3c2a6..96775bbf 100644 --- a/lib/app/modules/chat/domain/exceptions/departure_time_exception.dart +++ b/lib/app/modules/chat/domain/exceptions/departure_time_exception.dart @@ -10,6 +10,8 @@ sealed class DepartureTimeException implements Exception { PotAlreadyClosedException; const factory DepartureTimeException.notInAvailableTimeRange() = NotInAvailableTimeRangeException; + const factory DepartureTimeException.unknownResponse(String invalidArgument) = + UnknownResponseException; const factory DepartureTimeException.networkError(String error) = NetworkErrorException; const factory DepartureTimeException.unknown(Object error) = UnknownException; @@ -52,6 +54,14 @@ class NotInAvailableTimeRangeException extends DepartureTimeException { 'DepartureTimeException.NotInAvailableTimeRangeException'; } +class UnknownResponseException extends DepartureTimeException { + final String invalidArgument; + const UnknownResponseException(this.invalidArgument); + @override + String toString() => + 'DepartureTimeException.UnknownResponseException(invalidArgument: $invalidArgument)'; +} + class NetworkErrorException extends DepartureTimeException { final String error; const NetworkErrorException(this.error); diff --git a/lib/app/modules/chat/domain/exceptions/leave_pot_exception.dart b/lib/app/modules/chat/domain/exceptions/leave_pot_exception.dart index 583b64a4..b2fb2c23 100644 --- a/lib/app/modules/chat/domain/exceptions/leave_pot_exception.dart +++ b/lib/app/modules/chat/domain/exceptions/leave_pot_exception.dart @@ -10,6 +10,8 @@ sealed class LeavePotException implements Exception { const factory LeavePotException.potNotExist() = PotNotExistException; const factory LeavePotException.potAlreadyClosed() = PotAlreadyClosedException; + const factory LeavePotException.unknownResponse(String invalidArgument) = + UnknownResponseException; const factory LeavePotException.networkError(String error) = NetworkErrorException; const factory LeavePotException.unknown(Object error) = UnknownException; @@ -45,6 +47,13 @@ class PotAlreadyClosedException extends LeavePotException { String toString() => 'LeavePotException.PotAlreadyClosedException'; } +class UnknownResponseException extends LeavePotException { + final String invalidArgument; + const UnknownResponseException(this.invalidArgument); + @override + String toString() => 'LeavePotException.UnknownResponseException(invalidArgument: $invalidArgument)'; +} + class NetworkErrorException extends LeavePotException { final String error; const NetworkErrorException(this.error); diff --git a/lib/app/modules/chat/domain/exceptions/report_exception.dart b/lib/app/modules/chat/domain/exceptions/report_exception.dart index 2cbfd3a8..a1fa141a 100644 --- a/lib/app/modules/chat/domain/exceptions/report_exception.dart +++ b/lib/app/modules/chat/domain/exceptions/report_exception.dart @@ -5,12 +5,31 @@ sealed class ReportException implements Exception { const factory ReportException.networkError(String error, [String? errorId]) = ReportNetworkException; + const factory ReportException.unknownResponse( + String invalidArgument, [ + String? errorId, + ]) = ReportUnknownResponseException; const factory ReportException.unknown(Object error, [String? errorId]) = ReportUnknownException; ReportException withErrorId(String errorId); } +class ReportUnknownResponseException extends ReportException { + final String invalidArgument; + @override + final String? errorId; + const ReportUnknownResponseException(this.invalidArgument, [this.errorId]); + + @override + ReportException withErrorId(String errorId) => + ReportException.unknownResponse(invalidArgument, errorId); + + @override + String toString() => + 'ReportException.ReportUnknownResponseException(invalidArgument: $invalidArgument, errorId: $errorId)'; +} + class ReportNetworkException extends ReportException { final String error; @override diff --git a/lib/app/modules/create/domain/exceptions/create_pot_exception.dart b/lib/app/modules/create/domain/exceptions/create_pot_exception.dart index f325805b..9007ed8f 100644 --- a/lib/app/modules/create/domain/exceptions/create_pot_exception.dart +++ b/lib/app/modules/create/domain/exceptions/create_pot_exception.dart @@ -8,6 +8,8 @@ sealed class CreatePotException implements Exception { InvalidDepartureAvailableTimeException; const factory CreatePotException.tooFarDepartureAvailableTime() = TooFarDepartureAvailableTimeException; + const factory CreatePotException.unknownResponse(String invalidArgument) = + UnknownResponseException; const factory CreatePotException.networkError(String error) = NetworkErrorException; const factory CreatePotException.unknown(Object error) = UnknownException; @@ -29,6 +31,14 @@ class TooFarDepartureAvailableTimeException extends CreatePotException { const TooFarDepartureAvailableTimeException(); } +class UnknownResponseException extends CreatePotException { + final String invalidArgument; + const UnknownResponseException(this.invalidArgument); + @override + String toString() => + 'CreatePotException.UnknownResponseException(invalidArgument: $invalidArgument)'; +} + class NetworkErrorException extends CreatePotException { final String error; const NetworkErrorException(this.error); diff --git a/lib/app/modules/list/domain/exceptions/join_pot_exception.dart b/lib/app/modules/list/domain/exceptions/join_pot_exception.dart index eed5096e..0bee0dcb 100644 --- a/lib/app/modules/list/domain/exceptions/join_pot_exception.dart +++ b/lib/app/modules/list/domain/exceptions/join_pot_exception.dart @@ -8,6 +8,8 @@ sealed class JoinPotException implements Exception { const factory JoinPotException.potNotExist() = PotNotExistException; const factory JoinPotException.potAlreadyClosed() = PotAlreadyClosedException; const factory JoinPotException.potFull() = PotFullException; + const factory JoinPotException.unknownResponse(String invalidArgument) = + UnknownResponseException; const factory JoinPotException.networkError(String error) = NetworkErrorException; const factory JoinPotException.unknown(Object error) = UnknownException; @@ -37,6 +39,14 @@ class PotFullException extends JoinPotException { String toString() => 'JoinPotException.PotFullException'; } +class UnknownResponseException extends JoinPotException { + final String invalidArgument; + const UnknownResponseException(this.invalidArgument); + @override + String toString() => + 'JoinPotException.UnknownResponseException(invalidArgument: $invalidArgument)'; +} + class NetworkErrorException extends JoinPotException { final String error; const NetworkErrorException(this.error); From 0c54248214a3455425f0ff387e3d25b4dfb011c2 Mon Sep 17 00:00:00 2001 From: tkjftkjf Date: Sun, 30 Nov 2025 14:10:58 +0900 Subject: [PATCH 10/13] feat: implement error handling on presentation exception extension --- .../chat/presentation/extensions/pot_action_exception.dart | 4 ++++ .../presentation/extensions/report_exception_extension.dart | 1 + .../modules/create/presentation/extensions/create_error.dart | 2 ++ .../list/presentation/extensions/join_pot_exception.dart | 2 ++ 4 files changed, 9 insertions(+) diff --git a/lib/app/modules/chat/presentation/extensions/pot_action_exception.dart b/lib/app/modules/chat/presentation/extensions/pot_action_exception.dart index d4af310f..0e7c49d9 100644 --- a/lib/app/modules/chat/presentation/extensions/pot_action_exception.dart +++ b/lib/app/modules/chat/presentation/extensions/pot_action_exception.dart @@ -21,6 +21,8 @@ extension LeavePotExceptionX on leave.LeavePotException { return errors.pot_not_exist; case leave.PotAlreadyClosedException(): return errors.pot_already_closed; + case leave.UnknownResponseException(): + return errors.unknown; case leave.NetworkErrorException(): return errors.network_error; case leave.UnknownException(): @@ -73,6 +75,8 @@ extension DepartureTimeExceptionX on departure.DepartureTimeException { return errors.pot_already_closed; case departure.NotInAvailableTimeRangeException(): return errors.not_in_available_time_range; + case departure.UnknownResponseException(): + return errors.unknown; case departure.NetworkErrorException(): return errors.network_error; case departure.UnknownException(): diff --git a/lib/app/modules/chat/presentation/extensions/report_exception_extension.dart b/lib/app/modules/chat/presentation/extensions/report_exception_extension.dart index d09ca701..290780da 100644 --- a/lib/app/modules/chat/presentation/extensions/report_exception_extension.dart +++ b/lib/app/modules/chat/presentation/extensions/report_exception_extension.dart @@ -7,6 +7,7 @@ extension ReportExceptionX on ReportException { final errors = context.t.chat_room.drawer.actions.report.error; final message = switch (this) { ReportNetworkException() => errors.network_error, + ReportUnknownResponseException() => errors.unknown, ReportUnknownException() => errors.unknown, }; return '$message ($errorId)'; diff --git a/lib/app/modules/create/presentation/extensions/create_error.dart b/lib/app/modules/create/presentation/extensions/create_error.dart index ff30d7e9..d3a22025 100644 --- a/lib/app/modules/create/presentation/extensions/create_error.dart +++ b/lib/app/modules/create/presentation/extensions/create_error.dart @@ -14,6 +14,8 @@ extension CreateErrorX on CreatePotException { return errors.invalid_departure_available_time; case TooFarDepartureAvailableTimeException(): return errors.too_far_departure_available_time; + case UnknownResponseException(): + return errors.unknown; case NetworkErrorException(): return errors.network_error; case UnknownException(): diff --git a/lib/app/modules/list/presentation/extensions/join_pot_exception.dart b/lib/app/modules/list/presentation/extensions/join_pot_exception.dart index 8ef85817..548e2cfe 100644 --- a/lib/app/modules/list/presentation/extensions/join_pot_exception.dart +++ b/lib/app/modules/list/presentation/extensions/join_pot_exception.dart @@ -14,6 +14,8 @@ extension JoinPotExceptionX on JoinPotException { return errors.pot_already_closed; case PotFullException(): return errors.pot_full; + case UnknownResponseException(): + return errors.unknown; case NetworkErrorException(): return errors.network_error; case UnknownException(): From 2818da1138d9898a5f999ff5146a339130228bdb Mon Sep 17 00:00:00 2001 From: tkjftkjf Date: Sun, 30 Nov 2025 14:11:43 +0900 Subject: [PATCH 11/13] feat: implement error handling on data repositories --- .../chat/data/repositories/rest_report_repository.dart | 2 ++ .../repositories/websocket_pot_accounting_repository.dart | 4 ++++ .../data/repositories/websocket_pot_action_repository.dart | 4 ++++ .../create/data/repositories/rest_create_pot_repository.dart | 2 ++ .../list/data/repositories/rest_join_pot_repository.dart | 2 ++ 5 files changed, 14 insertions(+) diff --git a/lib/app/modules/chat/data/repositories/rest_report_repository.dart b/lib/app/modules/chat/data/repositories/rest_report_repository.dart index 3e949de9..f09ef1e7 100644 --- a/lib/app/modules/chat/data/repositories/rest_report_repository.dart +++ b/lib/app/modules/chat/data/repositories/rest_report_repository.dart @@ -35,6 +35,8 @@ class RestReportRepository implements ReportRepository { (e.message ?? 'Network error') : e.message ?? 'Network error'; throw ReportException.networkError(message); + } on ArgumentError catch (e) { + throw ReportException.unknownResponse(e.invalidValue); } catch (e) { throw ReportException.unknown(e); } diff --git a/lib/app/modules/chat/data/repositories/websocket_pot_accounting_repository.dart b/lib/app/modules/chat/data/repositories/websocket_pot_accounting_repository.dart index 99090c9e..4516c30b 100644 --- a/lib/app/modules/chat/data/repositories/websocket_pot_accounting_repository.dart +++ b/lib/app/modules/chat/data/repositories/websocket_pot_accounting_repository.dart @@ -59,6 +59,8 @@ class WebsocketPotAccountingRepository implements PotAccountingRepository { throw AccountingRequestException.networkError( e.message ?? e.error.toString(), ); + } on ArgumentError catch (e) { + throw AccountingRequestException.unknownResponse(e.invalidValue); } } @@ -90,6 +92,8 @@ class WebsocketPotAccountingRepository implements PotAccountingRepository { throw AccountingConfirmException.networkError( e.message ?? e.error.toString(), ); + } on ArgumentError catch (e) { + throw AccountingConfirmException.unknownResponse(e.invalidValue); } } diff --git a/lib/app/modules/chat/data/repositories/websocket_pot_action_repository.dart b/lib/app/modules/chat/data/repositories/websocket_pot_action_repository.dart index 5213199d..3649aa65 100644 --- a/lib/app/modules/chat/data/repositories/websocket_pot_action_repository.dart +++ b/lib/app/modules/chat/data/repositories/websocket_pot_action_repository.dart @@ -45,6 +45,8 @@ class WebsocketPotActionRepository implements PotActionRepository { throw DepartureTimeException.networkError( e.message ?? e.error.toString(), ); + } on ArgumentError catch (e) { + throw DepartureTimeException.unknownResponse(e.invalidValue); } } @@ -97,6 +99,8 @@ class WebsocketPotActionRepository implements PotActionRepository { } } on DioException catch (e) { throw LeavePotException.networkError(e.message ?? e.error.toString()); + } on ArgumentError catch (e) { + throw LeavePotException.unknownResponse(e.invalidValue); } } } diff --git a/lib/app/modules/create/data/repositories/rest_create_pot_repository.dart b/lib/app/modules/create/data/repositories/rest_create_pot_repository.dart index 910258d3..a0b35e90 100644 --- a/lib/app/modules/create/data/repositories/rest_create_pot_repository.dart +++ b/lib/app/modules/create/data/repositories/rest_create_pot_repository.dart @@ -46,6 +46,8 @@ class RestCreatePotRepository implements CreatePotRepository { } } on DioException catch (e) { throw CreatePotException.networkError(e.error.toString()); + } on ArgumentError catch (e) { + throw CreatePotException.unknownResponse(e.invalidValue); } } } diff --git a/lib/app/modules/list/data/repositories/rest_join_pot_repository.dart b/lib/app/modules/list/data/repositories/rest_join_pot_repository.dart index bc06fdeb..54641e1e 100644 --- a/lib/app/modules/list/data/repositories/rest_join_pot_repository.dart +++ b/lib/app/modules/list/data/repositories/rest_join_pot_repository.dart @@ -29,6 +29,8 @@ class RestJoinPotRepository implements JoinPotRepository { } } on DioException catch (e) { throw JoinPotException.networkError(e.error.toString()); + } on ArgumentError catch (e) { + throw JoinPotException.unknownResponse(e.invalidValue); } } } From b1741238d90416cae1ac0be2059230c989030601 Mon Sep 17 00:00:00 2001 From: tkjftkjf Date: Sun, 30 Nov 2025 14:34:25 +0900 Subject: [PATCH 12/13] fix: implement error messages --- lib/app/modules/chat/presentation/pages/accounting_page.dart | 1 + lib/app/modules/chat/presentation/widgets/pot_accounting.dart | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/app/modules/chat/presentation/pages/accounting_page.dart b/lib/app/modules/chat/presentation/pages/accounting_page.dart index dd67fa2a..df4dc70c 100644 --- a/lib/app/modules/chat/presentation/pages/accounting_page.dart +++ b/lib/app/modules/chat/presentation/pages/accounting_page.dart @@ -56,6 +56,7 @@ class AccountingPage extends StatelessWidget { NotAParticipantException() => errors.not_a_participant, PotNotExistException() => errors.pot_not_exist, PotAlreadyClosedException() => errors.pot_already_closed, + UnknownResponseException() => errors.unknown, NetworkErrorException() => errors.network_error, UnknownException() => errors.unknown, }; diff --git a/lib/app/modules/chat/presentation/widgets/pot_accounting.dart b/lib/app/modules/chat/presentation/widgets/pot_accounting.dart index 2f32fa02..4507cf14 100644 --- a/lib/app/modules/chat/presentation/widgets/pot_accounting.dart +++ b/lib/app/modules/chat/presentation/widgets/pot_accounting.dart @@ -70,6 +70,7 @@ class _PotAccountingState extends State { errors.not_accounting_requester, PotNotExistException() => errors.pot_not_exist, PotAlreadyClosedException() => errors.pot_already_closed, + UnknownResponseException() => errors.unknown, NetworkErrorException() => errors.network_error, UnknownException() => errors.unknown, }; From 18bfd4635b644a0bbdcfc95a5e0ef214034ecff1 Mon Sep 17 00:00:00 2001 From: tkjftkjf Date: Sun, 30 Nov 2025 16:29:21 +0900 Subject: [PATCH 13/13] feat: add toString method --- .../chat/data/repositories/rest_report_repository.dart | 2 +- .../repositories/websocket_pot_accounting_repository.dart | 8 ++++++-- .../repositories/websocket_pot_action_repository.dart | 6 +++--- .../data/repositories/rest_create_pot_repository.dart | 2 +- .../list/data/repositories/rest_join_pot_repository.dart | 2 +- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/app/modules/chat/data/repositories/rest_report_repository.dart b/lib/app/modules/chat/data/repositories/rest_report_repository.dart index f09ef1e7..c414f120 100644 --- a/lib/app/modules/chat/data/repositories/rest_report_repository.dart +++ b/lib/app/modules/chat/data/repositories/rest_report_repository.dart @@ -36,7 +36,7 @@ class RestReportRepository implements ReportRepository { : e.message ?? 'Network error'; throw ReportException.networkError(message); } on ArgumentError catch (e) { - throw ReportException.unknownResponse(e.invalidValue); + throw ReportException.unknownResponse(e.invalidValue.toString()); } catch (e) { throw ReportException.unknown(e); } diff --git a/lib/app/modules/chat/data/repositories/websocket_pot_accounting_repository.dart b/lib/app/modules/chat/data/repositories/websocket_pot_accounting_repository.dart index 4516c30b..afc62e03 100644 --- a/lib/app/modules/chat/data/repositories/websocket_pot_accounting_repository.dart +++ b/lib/app/modules/chat/data/repositories/websocket_pot_accounting_repository.dart @@ -60,7 +60,9 @@ class WebsocketPotAccountingRepository implements PotAccountingRepository { e.message ?? e.error.toString(), ); } on ArgumentError catch (e) { - throw AccountingRequestException.unknownResponse(e.invalidValue); + throw AccountingRequestException.unknownResponse( + e.invalidValue.toString(), + ); } } @@ -93,7 +95,9 @@ class WebsocketPotAccountingRepository implements PotAccountingRepository { e.message ?? e.error.toString(), ); } on ArgumentError catch (e) { - throw AccountingConfirmException.unknownResponse(e.invalidValue); + throw AccountingConfirmException.unknownResponse( + e.invalidValue.toString(), + ); } } diff --git a/lib/app/modules/chat/data/repositories/websocket_pot_action_repository.dart b/lib/app/modules/chat/data/repositories/websocket_pot_action_repository.dart index 3649aa65..f740c190 100644 --- a/lib/app/modules/chat/data/repositories/websocket_pot_action_repository.dart +++ b/lib/app/modules/chat/data/repositories/websocket_pot_action_repository.dart @@ -46,7 +46,7 @@ class WebsocketPotActionRepository implements PotActionRepository { e.message ?? e.error.toString(), ); } on ArgumentError catch (e) { - throw DepartureTimeException.unknownResponse(e.invalidValue); + throw DepartureTimeException.unknownResponse(e.invalidValue.toString()); } } @@ -75,7 +75,7 @@ class WebsocketPotActionRepository implements PotActionRepository { } on DioException catch (e) { throw KickUserException.networkError(e.message ?? e.error.toString()); } on ArgumentError catch (e) { - throw KickUserException.unknownResponse(e.invalidValue); + throw KickUserException.unknownResponse(e.invalidValue.toString()); } } @@ -100,7 +100,7 @@ class WebsocketPotActionRepository implements PotActionRepository { } on DioException catch (e) { throw LeavePotException.networkError(e.message ?? e.error.toString()); } on ArgumentError catch (e) { - throw LeavePotException.unknownResponse(e.invalidValue); + throw LeavePotException.unknownResponse(e.invalidValue.toString()); } } } diff --git a/lib/app/modules/create/data/repositories/rest_create_pot_repository.dart b/lib/app/modules/create/data/repositories/rest_create_pot_repository.dart index a0b35e90..2ada96ae 100644 --- a/lib/app/modules/create/data/repositories/rest_create_pot_repository.dart +++ b/lib/app/modules/create/data/repositories/rest_create_pot_repository.dart @@ -47,7 +47,7 @@ class RestCreatePotRepository implements CreatePotRepository { } on DioException catch (e) { throw CreatePotException.networkError(e.error.toString()); } on ArgumentError catch (e) { - throw CreatePotException.unknownResponse(e.invalidValue); + throw CreatePotException.unknownResponse(e.invalidValue.toString()); } } } diff --git a/lib/app/modules/list/data/repositories/rest_join_pot_repository.dart b/lib/app/modules/list/data/repositories/rest_join_pot_repository.dart index 54641e1e..20147bdd 100644 --- a/lib/app/modules/list/data/repositories/rest_join_pot_repository.dart +++ b/lib/app/modules/list/data/repositories/rest_join_pot_repository.dart @@ -30,7 +30,7 @@ class RestJoinPotRepository implements JoinPotRepository { } on DioException catch (e) { throw JoinPotException.networkError(e.error.toString()); } on ArgumentError catch (e) { - throw JoinPotException.unknownResponse(e.invalidValue); + throw JoinPotException.unknownResponse(e.invalidValue.toString()); } } }