Skip to content

Commit 99ef00e

Browse files
committed
feat(authentication): adapt bloc to handle HtHttpException
Updates `AuthenticationBloc` to handle and emit `HtHttpException` objects instead of raw error strings. - All `catch` blocks now store the caught exception in the `exception` field of the `AuthenticationState`. - The manual email validation check is removed, as this logic is now handled by the `InvalidInputException` from the repository layer. - Generic `catch (e)` blocks now wrap the error in a `UnknownException` to ensure all failures are propagated as a standard exception type.
1 parent c2935df commit 99ef00e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/authentication/view/email_code_verification_page.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import 'package:ht_dashboard/app/bloc/app_bloc.dart';
55
import 'package:ht_dashboard/app/config/config.dart';
66
import 'package:ht_dashboard/authentication/bloc/authentication_bloc.dart';
77
import 'package:ht_dashboard/l10n/l10n.dart';
8+
import 'package:ht_ui_kit/ht_ui_kit.dart';
89
import 'package:ht_dashboard/shared/constants/app_spacing.dart';
910

1011
/// {@template email_code_verification_page}
@@ -29,12 +30,13 @@ class EmailCodeVerificationPage extends StatelessWidget {
2930
body: SafeArea(
3031
child: BlocConsumer<AuthenticationBloc, AuthenticationState>(
3132
listener: (context, state) {
32-
if (state.status == AuthenticationStatus.failure) {
33+
if (state.status == AuthenticationStatus.failure &&
34+
state.exception != null) {
3335
ScaffoldMessenger.of(context)
3436
..hideCurrentSnackBar()
3537
..showSnackBar(
3638
SnackBar(
37-
content: Text(state.errorMessage!),
39+
content: Text(state.exception!.toFriendlyMessage(context)),
3840
backgroundColor: colorScheme.error,
3941
),
4042
);

0 commit comments

Comments
 (0)