Change ip error
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -129,6 +129,7 @@ class ProxyRepositoryImpl
|
||||
TaskEither<ProxyFailure, IpInfo> 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,
|
||||
);
|
||||
|
||||
@@ -20,6 +20,12 @@ sealed class ProxyFailure with _$ProxyFailure, Failure {
|
||||
@With<ExpectedFailure>()
|
||||
const factory ProxyFailure.unknownIp() = UnknownIp;
|
||||
|
||||
@With<ExpectedMeasuredFailure>()
|
||||
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,
|
||||
),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user