Skip to content

Commit 1f99267

Browse files
committed
fix(content_management): Handle exceptions more robustly
- Replaced errorMessage with exception property - Improved error handling for all bloc events - Used UnknownException for unexpected errors
1 parent 33e0e21 commit 1f99267

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

lib/content_management/bloc/content_management_bloc.dart

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ class ContentManagementBloc
7878
emit(
7979
state.copyWith(
8080
headlinesStatus: ContentManagementStatus.failure,
81-
errorMessage: e.message,
81+
exception: e,
8282
),
8383
);
8484
} catch (e) {
8585
emit(
8686
state.copyWith(
8787
headlinesStatus: ContentManagementStatus.failure,
88-
errorMessage: e.toString(),
88+
exception: UnknownException('An unexpected error occurred: $e'),
8989
),
9090
);
9191
}
@@ -105,14 +105,14 @@ class ContentManagementBloc
105105
emit(
106106
state.copyWith(
107107
headlinesStatus: ContentManagementStatus.failure,
108-
errorMessage: e.message,
108+
exception: e,
109109
),
110110
);
111111
} catch (e) {
112112
emit(
113113
state.copyWith(
114114
headlinesStatus: ContentManagementStatus.failure,
115-
errorMessage: e.toString(),
115+
exception: UnknownException('An unexpected error occurred: $e'),
116116
),
117117
);
118118
}
@@ -157,14 +157,14 @@ class ContentManagementBloc
157157
emit(
158158
state.copyWith(
159159
topicsStatus: ContentManagementStatus.failure,
160-
errorMessage: e.message,
160+
exception: e,
161161
),
162162
);
163163
} catch (e) {
164164
emit(
165165
state.copyWith(
166166
topicsStatus: ContentManagementStatus.failure,
167-
errorMessage: e.toString(),
167+
exception: UnknownException('An unexpected error occurred: $e'),
168168
),
169169
);
170170
}
@@ -184,14 +184,14 @@ class ContentManagementBloc
184184
emit(
185185
state.copyWith(
186186
topicsStatus: ContentManagementStatus.failure,
187-
errorMessage: e.message,
187+
exception: e,
188188
),
189189
);
190190
} catch (e) {
191191
emit(
192192
state.copyWith(
193193
topicsStatus: ContentManagementStatus.failure,
194-
errorMessage: e.toString(),
194+
exception: UnknownException('An unexpected error occurred: $e'),
195195
),
196196
);
197197
}
@@ -236,14 +236,14 @@ class ContentManagementBloc
236236
emit(
237237
state.copyWith(
238238
sourcesStatus: ContentManagementStatus.failure,
239-
errorMessage: e.message,
239+
exception: e,
240240
),
241241
);
242242
} catch (e) {
243243
emit(
244244
state.copyWith(
245245
sourcesStatus: ContentManagementStatus.failure,
246-
errorMessage: e.toString(),
246+
exception: UnknownException('An unexpected error occurred: $e'),
247247
),
248248
);
249249
}
@@ -263,14 +263,14 @@ class ContentManagementBloc
263263
emit(
264264
state.copyWith(
265265
sourcesStatus: ContentManagementStatus.failure,
266-
errorMessage: e.message,
266+
exception: e,
267267
),
268268
);
269269
} catch (e) {
270270
emit(
271271
state.copyWith(
272272
sourcesStatus: ContentManagementStatus.failure,
273-
errorMessage: e.toString(),
273+
exception: UnknownException('An unexpected error occurred: $e'),
274274
),
275275
);
276276
}

0 commit comments

Comments
 (0)