Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
);
}
}

Expand Down Expand Up @@ -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(),
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}

Expand Down Expand Up @@ -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());
}
}

Expand All @@ -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());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) =
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) =
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 10 additions & 0 deletions lib/app/modules/chat/domain/exceptions/kick_user_exception.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
19 changes: 19 additions & 0 deletions lib/app/modules/chat/domain/exceptions/report_exception.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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():
Expand All @@ -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():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class _PotAccountingState extends State<PotAccounting> {
errors.not_accounting_requester,
PotNotExistException() => errors.pot_not_exist,
PotAlreadyClosedException() => errors.pot_already_closed,
UnknownResponseException() => errors.unknown,
NetworkErrorException() => errors.network_error,
UnknownException() => errors.unknown,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}
10 changes: 10 additions & 0 deletions lib/app/modules/create/domain/exceptions/create_pot_exception.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}
10 changes: 10 additions & 0 deletions lib/app/modules/list/domain/exceptions/join_pot_exception.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down