Skip to content

Commit 32c33b8

Browse files
committed
feat(authentication): add specific error handling for dashboard login
This change enhances the AuthenticationBloc by adding specific `catch` blocks for `UnauthorizedException`, `ForbiddenException`, and `NotFoundException`. This ensures that the UI can display precise error messages to the user during the dashboard-specific authentication flow, aligning with the updated `HtAuthClient` contract.
1 parent 71876ca commit 32c33b8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/authentication/bloc/authentication_bloc.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@ import 'package:ht_auth_repository/ht_auth_repository.dart';
66
import 'package:ht_shared/ht_shared.dart'
77
show
88
AuthenticationException,
9+
ForbiddenException,
910
HtHttpException,
1011
InvalidInputException,
1112
NetworkException,
13+
NotFoundException,
1214
OperationFailedException,
1315
ServerException,
16+
UnauthorizedException,
1417
User;
1518

1619
part 'authentication_event.dart';
@@ -72,6 +75,10 @@ class AuthenticationBloc
7275
emit(AuthenticationCodeSentSuccess(email: event.email));
7376
} on InvalidInputException catch (e) {
7477
emit(AuthenticationFailure('Invalid input: ${e.message}'));
78+
} on UnauthorizedException catch (e) {
79+
emit(AuthenticationFailure(e.message));
80+
} on ForbiddenException catch (e) {
81+
emit(AuthenticationFailure(e.message));
7582
} on NetworkException catch (_) {
7683
emit(const AuthenticationFailure('Network error occurred.'));
7784
} on ServerException catch (e) {
@@ -109,6 +116,8 @@ class AuthenticationBloc
109116
emit(AuthenticationFailure(e.message));
110117
} on AuthenticationException catch (e) {
111118
emit(AuthenticationFailure(e.message));
119+
} on NotFoundException catch (e) {
120+
emit(AuthenticationFailure(e.message));
112121
} on NetworkException catch (_) {
113122
emit(const AuthenticationFailure('Network error occurred.'));
114123
} on ServerException catch (e) {

0 commit comments

Comments
 (0)