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..c414f120 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.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 99090c9e..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 @@ -59,6 +59,10 @@ class WebsocketPotAccountingRepository implements PotAccountingRepository { throw AccountingRequestException.networkError( e.message ?? e.error.toString(), ); + } on ArgumentError catch (e) { + throw AccountingRequestException.unknownResponse( + e.invalidValue.toString(), + ); } } @@ -90,6 +94,10 @@ class WebsocketPotAccountingRepository implements PotAccountingRepository { throw AccountingConfirmException.networkError( e.message ?? e.error.toString(), ); + } on ArgumentError catch (e) { + 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 97e02889..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 @@ -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.toString()); } } @@ -72,6 +74,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.invalidValue.toString()); } } @@ -95,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.toString()); } } } 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/kick_user_exception.dart b/lib/app/modules/chat/domain/exceptions/kick_user_exception.dart index 6a10f6bb..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,6 +13,8 @@ sealed class KickUserException implements Exception { const factory KickUserException.potNotExist() = PotNotExistException; const factory KickUserException.potAlreadyClosed() = PotAlreadyClosedException; + const factory KickUserException.unknownResponse(String invalidArgument) = + UnknownResponseException; const factory KickUserException.networkError(String error) = NetworkErrorException; const factory KickUserException.unknown(Object error) = UnknownException; @@ -60,6 +62,14 @@ class PotAlreadyClosedException extends KickUserException { String toString() => 'KickUserException.PotAlreadyClosedException'; } +class UnknownResponseException extends KickUserException { + final String invalidArgument; + const UnknownResponseException(this.invalidArgument); + @override + String toString() => + 'KickUserException.UnknownResponseException(invalid argument: $invalidArgument)'; +} + class NetworkErrorException extends KickUserException { 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/chat/presentation/extensions/pot_action_exception.dart b/lib/app/modules/chat/presentation/extensions/pot_action_exception.dart index b4a55e3f..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(): @@ -47,6 +49,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(): @@ -71,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/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, }; 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..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 @@ -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.toString()); } } } 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/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/data/repositories/rest_join_pot_repository.dart b/lib/app/modules/list/data/repositories/rest_join_pot_repository.dart index bc06fdeb..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 @@ -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.toString()); } } } 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); 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():