diff --git a/data/lib/errors/app_error.dart b/data/lib/errors/app_error.dart index f266686..711b037 100644 --- a/data/lib/errors/app_error.dart +++ b/data/lib/errors/app_error.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:data/errors/l10n_error_codes.dart'; class AppError implements Exception { @@ -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 {