Skip to content

Commit

Permalink
Implement error manager
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-pratik-k committed Jan 29, 2024
1 parent 9b24001 commit f2ce033
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions data/lib/errors/app_error.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:io';

import 'package:data/errors/l10n_error_codes.dart';

class AppError implements Exception {
Expand All @@ -11,6 +13,14 @@ class AppError implements Exception {
String toString() {
return '$runtimeType{message: $message, code: $statusCode, l10nCode: $l10nCode}';
}

factory AppError.fromError(Object error) {
if (error is SocketException) {
return const NoConnectionError();
} else {
return const SomethingWentWrongError();
}
}
}

class NoConnectionError extends AppError {
Expand Down

0 comments on commit f2ce033

Please sign in to comment.