diff --git a/lib/features/proxy/active/active_proxy_notifier.dart b/lib/features/proxy/active/active_proxy_notifier.dart index 6b7cb260..c3879dd6 100644 --- a/lib/features/proxy/active/active_proxy_notifier.dart +++ b/lib/features/proxy/active/active_proxy_notifier.dart @@ -51,7 +51,7 @@ class IpInfoNotifier extends _$IpInfoNotifier with AppLogger { .getCurrentIpInfo(cancelToken) .getOrElse( (err) { - loggy.error("error getting proxy ip info", err); + loggy.warning("error getting proxy ip info", err, StackTrace.current); throw err; }, ).run(); @@ -111,7 +111,7 @@ class ActiveProxyNotifier extends _$ActiveProxyNotifier with AppLogger { .read(proxyRepositoryProvider) .urlTest(groupTag) .getOrElse((err) { - loggy.error("error testing group", err); + loggy.warning("error testing group", err); throw err; }).run(); } diff --git a/lib/features/proxy/data/proxy_repository.dart b/lib/features/proxy/data/proxy_repository.dart index 8d931d50..53c66f27 100644 --- a/lib/features/proxy/data/proxy_repository.dart +++ b/lib/features/proxy/data/proxy_repository.dart @@ -129,6 +129,7 @@ class ProxyRepositoryImpl TaskEither getCurrentIpInfo(CancelToken cancelToken) { return TaskEither.tryCatch( () async { + Object? error; for (final source in _ipInfoSources.entries) { try { loggy.debug("getting current ip info using [${source.key}]"); @@ -139,12 +140,13 @@ class ProxyRepositoryImpl if (response.statusCode == 200 && response.data != null) { return source.value(response.data!); } - } catch (e) { - loggy.debug("failed getting ip info using [${source.key}]", e); + } catch (e, s) { + loggy.debug("failed getting ip info using [${source.key}]", e, s); + error = e; continue; } } - throw const ProxyFailure.unexpected(); + throw UnableToRetrieveIp(error, StackTrace.current); }, ProxyUnexpectedFailure.new, ); diff --git a/lib/features/proxy/model/proxy_failure.dart b/lib/features/proxy/model/proxy_failure.dart index 7645bff6..c6591ee0 100644 --- a/lib/features/proxy/model/proxy_failure.dart +++ b/lib/features/proxy/model/proxy_failure.dart @@ -20,6 +20,12 @@ sealed class ProxyFailure with _$ProxyFailure, Failure { @With() const factory ProxyFailure.unknownIp() = UnknownIp; + @With() + const factory ProxyFailure.unableToRetrieveIp([ + Object? error, + StackTrace? stackTrace, + ]) = UnableToRetrieveIp; + @override ({String type, String? message}) present(TranslationsEn t) { return switch (this) { @@ -32,6 +38,10 @@ sealed class ProxyFailure with _$ProxyFailure, Failure { message: null, ), UnknownIp() => (type: t.general.unknown, message: null), + UnableToRetrieveIp() => ( + type: t.failure.unexpected, + message: null, + ), }; } }