Change ip error
This commit is contained in:
@@ -51,7 +51,7 @@ class IpInfoNotifier extends _$IpInfoNotifier with AppLogger {
|
|||||||
.getCurrentIpInfo(cancelToken)
|
.getCurrentIpInfo(cancelToken)
|
||||||
.getOrElse(
|
.getOrElse(
|
||||||
(err) {
|
(err) {
|
||||||
loggy.error("error getting proxy ip info", err);
|
loggy.warning("error getting proxy ip info", err, StackTrace.current);
|
||||||
throw err;
|
throw err;
|
||||||
},
|
},
|
||||||
).run();
|
).run();
|
||||||
@@ -111,7 +111,7 @@ class ActiveProxyNotifier extends _$ActiveProxyNotifier with AppLogger {
|
|||||||
.read(proxyRepositoryProvider)
|
.read(proxyRepositoryProvider)
|
||||||
.urlTest(groupTag)
|
.urlTest(groupTag)
|
||||||
.getOrElse((err) {
|
.getOrElse((err) {
|
||||||
loggy.error("error testing group", err);
|
loggy.warning("error testing group", err);
|
||||||
throw err;
|
throw err;
|
||||||
}).run();
|
}).run();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,6 +129,7 @@ class ProxyRepositoryImpl
|
|||||||
TaskEither<ProxyFailure, IpInfo> getCurrentIpInfo(CancelToken cancelToken) {
|
TaskEither<ProxyFailure, IpInfo> getCurrentIpInfo(CancelToken cancelToken) {
|
||||||
return TaskEither.tryCatch(
|
return TaskEither.tryCatch(
|
||||||
() async {
|
() async {
|
||||||
|
Object? error;
|
||||||
for (final source in _ipInfoSources.entries) {
|
for (final source in _ipInfoSources.entries) {
|
||||||
try {
|
try {
|
||||||
loggy.debug("getting current ip info using [${source.key}]");
|
loggy.debug("getting current ip info using [${source.key}]");
|
||||||
@@ -139,12 +140,13 @@ class ProxyRepositoryImpl
|
|||||||
if (response.statusCode == 200 && response.data != null) {
|
if (response.statusCode == 200 && response.data != null) {
|
||||||
return source.value(response.data!);
|
return source.value(response.data!);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e, s) {
|
||||||
loggy.debug("failed getting ip info using [${source.key}]", e);
|
loggy.debug("failed getting ip info using [${source.key}]", e, s);
|
||||||
|
error = e;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw const ProxyFailure.unexpected();
|
throw UnableToRetrieveIp(error, StackTrace.current);
|
||||||
},
|
},
|
||||||
ProxyUnexpectedFailure.new,
|
ProxyUnexpectedFailure.new,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -20,6 +20,12 @@ sealed class ProxyFailure with _$ProxyFailure, Failure {
|
|||||||
@With<ExpectedFailure>()
|
@With<ExpectedFailure>()
|
||||||
const factory ProxyFailure.unknownIp() = UnknownIp;
|
const factory ProxyFailure.unknownIp() = UnknownIp;
|
||||||
|
|
||||||
|
@With<ExpectedMeasuredFailure>()
|
||||||
|
const factory ProxyFailure.unableToRetrieveIp([
|
||||||
|
Object? error,
|
||||||
|
StackTrace? stackTrace,
|
||||||
|
]) = UnableToRetrieveIp;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
({String type, String? message}) present(TranslationsEn t) {
|
({String type, String? message}) present(TranslationsEn t) {
|
||||||
return switch (this) {
|
return switch (this) {
|
||||||
@@ -32,6 +38,10 @@ sealed class ProxyFailure with _$ProxyFailure, Failure {
|
|||||||
message: null,
|
message: null,
|
||||||
),
|
),
|
||||||
UnknownIp() => (type: t.general.unknown, message: null),
|
UnknownIp() => (type: t.general.unknown, message: null),
|
||||||
|
UnableToRetrieveIp() => (
|
||||||
|
type: t.failure.unexpected,
|
||||||
|
message: null,
|
||||||
|
),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user